run simulink with GUI with set_param()
1 view (last 30 days)
Show older comments
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
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
Answers (3)
Azzi Abdelmalek
on 10 May 2013
set_param allows to change any parameters block in your simulink model
1 Comment
Azzi Abdelmalek
on 10 May 2013
You can use
get_param('Steifigkeit','Dialogparameters');
sia
on 10 May 2013
1 Comment
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?
See Also
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!