MATLAB SIMULINK 7 - GRAPHICAL USER INTERFACE Manuel d'utilisateur Page 248

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 330
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 247
10 Examples of GUIDE GUIs
10-24
Calls model_open to ensure that the Simulink model is open so that
simulation parameters can be set.
Gets the new slider value.
Sets the value of the
Current value edit text component to match the slider.
Sets the appropriate block parameter to the new value (
set_param).
Here is the callback for the
Proportional (Kf) slider.
function KfValueSlider_Callback(hObject, eventdata, handles)
% Ensure model is open.
model_open(handles)
% Get the new value for the Kf Gain from the slider.
NewVal = get(hObject, 'Value');
% Set the value of the KfCurrentValue to the new value
% set by slider.
set(handles.KfCurrentValue,'String',NewVal)
% Set the Gain parameter of the Kf Gain Block to the new value.
set_param('f14/Controller/Gain','Gain',num2str(NewVal))
Note that, while a slider returns a number and the edit text requires a string,
uicontrols automatically convert the values to the correct type.
The callback for the
Integral (Ki) slider follows a similar approach.
Current Value Edit Text Callback
The edit text box enables users to type in a value for the respective parameter.
When the user clicks on another component in the GUI after typing into the
text box, the edit text callback executes the following steps:
Calls
model_open to ensure that the Simulink model is open so that it can set
simulation parameters.
Converts the string returned by the edit box
String property to a double
(
str2double).
Checks whether the value entered by the user is within the range of the
slider:
If the value is out of range, the edit text
String property is set to the value
of the slider (rejecting the number typed in by the user).
If the value is in range, the slider
Value property is updated to the new value.
Sets the appropriate block parameter to the new value (
set_param).
Vue de la page 247
1 2 ... 243 244 245 246 247 248 249 250 251 252 253 ... 329 330

Commentaires sur ces manuels

Pas de commentaire