Borrar filtros
Borrar filtros

run simulink with GUI with set_param()

1 visualización (últimos 30 días)
sia
sia el 10 de Mayo de 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 comentario
Rohit
Rohit el 27 de Jun. de 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

Iniciar sesión para comentar.

Respuestas (3)

Azzi Abdelmalek
Azzi Abdelmalek el 10 de Mayo de 2013
set_param allows to change any parameters block in your simulink model
Look at set_param
  1 comentario
Azzi Abdelmalek
Azzi Abdelmalek el 10 de Mayo de 2013
You can use
get_param('Steifigkeit','Dialogparameters');

Iniciar sesión para comentar.


sia
sia el 10 de Mayo de 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 comentario
Kaustubha Govind
Kaustubha Govind el 10 de Mayo de 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?

Iniciar sesión para comentar.


sia
sia el 10 de Mayo de 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 comentarios
Azzi Abdelmalek
Azzi Abdelmalek el 11 de Mayo de 2013
In Windows command
Rohit
Rohit el 27 de Jun. de 2013
Thanks a lot... that answered my question

Iniciar sesión para comentar.

Categorías

Más información sobre Simulink Environment Customization en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by