MATLAB SIMULINK 7 - GRAPHICAL USER INTERFACE Bedienungsanleitung Seite 224

  • Herunterladen
  • Zu meinen Handbüchern hinzufügen
  • Drucken
  • Seite
    / 330
  • Inhaltsverzeichnis
  • LESEZEICHEN
  • Bewertet. / 5. Basierend auf Kundenbewertungen
Seitenansicht 223
9 Managing Application-Defined Data
9-12
2 Set the edit text value from the slider Callback callback. Add this statement
to the slider
Callback.
set(handles.edit1,'String',...
num2str(get(handles.slider1,'Value')));
3 Set the slider value from the edit text Callback callback. To do this, add the
following code to the edit text
Callback.
To update the number or errors, the code must first retrieve the value of the
edit text
UserData property, then increment the count. It then saves the
updated error count in the
UserData property and displays the new count.
val = str2double(get(hObject,'String'));
% Determine whether val is a number between 0 and 1
if isnumeric(val) & length(val)==1 & ...
val >= get(handles.slider1,'Min') & ...
val <= get(handles.slider1,'Max')
set(handles.slider1,'Value',val);
else
% Retrieve and increment the error count.
number_errors = get(hObject,'UserData');
number_errors = number_errors+1;
% Save the changes.
set(hObject,'UserData',slider_data);
% Display new total.
set(hObject,'String',...
['You have entered an invalid entry ',...
num2str(number_errors),' times.']);
end
Seitenansicht 223
1 2 ... 219 220 221 222 223 224 225 226 227 228 229 ... 329 330

Kommentare zu diesen Handbüchern

Keine Kommentare