Clear Filters
Clear Filters

run simulink with GUI with set_param()

1 view (last 30 days)
sia
sia on 10 May 2013
Hi,
i wanna to edit 2 values in the GUI and with one button the simulnk gets these values and after the result should be displayed in the GUI.
but i dont understand set_param(). this is my code:
if true
function varargout = Gui(varargin)
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @Gui_OpeningFcn, ...
'gui_OutputFcn', @Gui_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% --- Executes just before Gui is made visible.
function Gui_OpeningFcn(hObject, eventdata, handles, varargin)
% Choose default command line output for Gui
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes Gui wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = Gui_OutputFcn(hObject, eventdata, handles)
% Get default command line output from handles structure
varargout{1} = handles.output;
function kraft_Callback(hObject, eventdata, handles)
kraft_value = str2num(get(hObject,'String'));
if (isempty(kraft_value))
set(hObject,'String','0')
end
guidata(hObject, handles);
function flaeche_Callback(hObject, eventdata, handles)
flaeche_value = str2num(get(hObject,'String'));
if (isempty(flaeche_value))
set(hObject,'String','0')
end
guidata(hObject, handles);
function start_Callback(hObject, eventdata, handles)
k = str2num(get(handles.kraft,'String'));
f = str2num(get(handles.flaeche,'String'));
set_param('Steifigkeit/k','String',num2str(k));
set_param('Steifigkeit/f','String',num2str(f));
set(handles.static,'String',spannung);
guidata(hObject, handles);
% --- Executes during object creation, after setting all properties.
function static_CreateFcn(hObject, eventdata, handles)
end
But i dont know what is the meaning of the parameters os set_param(). cann you help me pls?
  1 Comment
Rohit
Rohit on 27 Jun 2013
Hi, I am trying to use set_param for changing 'Initial output' parameter of 'Ramp' block.
I am doing this by using:
global a1
set_param([bdroot '/BR-KT Assembly-1/Motion input2/Ramp1'],'Slope',a1)
But it gives me an error message saying: Error using GUI_Rohit>StartSimulation_Callback (line 429) Ramp block (mask) does not have a parameter named 'Initial output'
Can you suggest something to eliminate this?
Thanks a lot
Rohit

Sign in to comment.

Answers (3)

Azzi Abdelmalek
Azzi Abdelmalek on 10 May 2013
set_param allows to change any parameters block in your simulink model
Look at set_param

sia
sia on 10 May 2013
I know this link, but i dont understand set_param(object,param,value) the objektname is the name of my .mdl ??
and what is param???
e.g. i have written
set_param('Steifigkeit','String',num2str(k));
where can i finde the name of my param????
  1 Comment
Kaustubha Govind
Kaustubha Govind on 10 May 2013
Sia: Not sure I understand your question. In this case, 'String' is the name of the parameter you are trying to set. Is that what you're asking?

Sign in to comment.


sia
sia on 10 May 2013
yes, it should be the name, but that is false "String". it should be what else, but i tried all of my parameters, but they are not the right name :(. how can i finde the right parameter ?
  5 Comments
Rohit
Rohit on 27 Jun 2013
Thanks a lot... that answered my question

Sign in to comment.

Categories

Find more on Programmatic Model Editing in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!