Specifications

A GUI to Set Simulink Model Parameters
5-31
Change the size of the controller Gain block so it can display the gain value
(
set_param).
Bring the GUI forward so it is displayed on top of the Simulink diagrams
(
figure).
Set the block parameters to match the current settings in the GUI.
Here is the code for the
model_open subfunction.
function model_open(handles)
if isempty(find_system('Name','f14')),
open_system('f14'); open_system('f14/Controller')
set_param('f14/Controller/Gain','Position',[275 14 340 56])
figure(handles.F14ControllerEditor)
set_param('f14/Controller Gain','Gain',...
get(handles.KfCurrentValue,'String'))
set_param('f14/Controller/Proportional plus integral compensator',...
'Numerator',...
get(handles.KiCurrentValue,'String'))
end
Programming the Slider and Edit Text Components
This GUI employs a useful combination of components in its design. Each
slider is coupled to an edit text component so that:
The edit text displays the current value of the slider.
The user can enter a value into the edit text box and cause the slider to
update to that value.
Both components update the appropriate model parameters when activated
by the user.
Slider Callback
The GUI uses two sliders to specify block gains since these components enable
the selection of continuous values within a specified range. When a user
changes the slider value, the callback executes the following steps:
Calls
model_open to ensure that the Simulink model is open so that
simulation parameters can be set.
Gets the new slider value.