필터 지우기
필터 지우기

run simulink with GUI with set_param()

조회 수: 1 (최근 30일)
sia
sia 2013년 5월 10일
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
Rohit
Rohit 2013년 6월 27일
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

댓글을 달려면 로그인하십시오.

답변 (3개)

Azzi Abdelmalek
Azzi Abdelmalek 2013년 5월 10일
set_param allows to change any parameters block in your simulink model
Look at set_param
  댓글 수: 1
Azzi Abdelmalek
Azzi Abdelmalek 2013년 5월 10일
You can use
get_param('Steifigkeit','Dialogparameters');

댓글을 달려면 로그인하십시오.


sia
sia 2013년 5월 10일
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
Kaustubha Govind
Kaustubha Govind 2013년 5월 10일
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?

댓글을 달려면 로그인하십시오.


sia
sia 2013년 5월 10일
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
Azzi Abdelmalek
Azzi Abdelmalek 2013년 5월 11일
In Windows command
Rohit
Rohit 2013년 6월 27일
Thanks a lot... that answered my question

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Simulink Environment Customization에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by