User`s guide
A GUI to Set Simulink
®
Model Parameters (GUIDE)
If the value is in range, the slide r Value property is updated to the new
value.
• Sets the appropriate block parameter to the new value (
set_param).
Here is the callback for the Kf Current value text box:
function KfCurr entV alue_Callback(hObject, eventdata, handles)
% Ensure model is open.
model_open(handles)
% Get the new value for the Kf Gain.
NewStrVal = get(hObject, 'Strin g');
NewVal = str2double(NewStrVal);
% Check that the entered va lue falls within th e allowable range.
if isempty(NewVal) || (NewVal< -5 ) || (NewVal>0),
% Revert to last value, as indicated by Kf Valu eSlider.
OldVal = get(handles.KfValueSli der,'Value');
set(hObject, 'String',OldVal)
else % Use new Kf value
% Set the value of the KfValueSlider to th e new value.
set(handles.KfValueSlider,'Value',Ne wVal)
% Set the Gain parameter of the Kf Gain Bl ock
% to the new value.
set_param('f14/Controller/Gain','Gai n',NewStrVal)
end
The callback for the Ki Current value follows a similar appro ach.
Run the Simulation from the GUI
The GUI Simulate and store results button callback runs the model
simulation and stores the results in the
handles structure. Storing data
in the
handles structure simplifies the process of passing data to other
subfunction since this structure can be passed as an argument.
When a user clicks the Sim u late and store results button, the callback
executes the following steps:
• Calls
sim, which runs the simulation and returns the data that is used
for plotting.
10-73