MATLAB SIMULINK 7 - GRAPHICAL USER INTERFACE Uživatelský manuál Strana 310

  • Stažení
  • Přidat do mých příruček
  • Tisk
  • Strana
    / 500
  • Tabulka s obsahem
  • KNIHY
  • Hodnocené. / 5. Na základě hodnocení zákazníků
Zobrazit stránku 309
9 Examples of GUIDE UIs
9-64
% Store the new ResultsData
handles.ResultsData = ResultsData;
guidata(hObject, handles)
Remove Results from List Box
The Remove button callback deletes any selected item from the Resultslist list box. It
also deletes the corresponding run data from the handles structure. When you click the
Remove button, the callback performs these tasks:
Determines which list box items are selected when you click the Remove button and
remove those items from the list box String property by setting each item to the
empty matrix [].
Removes the deleted data from the handles structure.
Displays the string <empty> and disables the Remove and Plot buttons (using the
Enable property), if all the items in the list box are removed.
Save the changes to the handles structure (guidata).
Here is the Remove button callback:
function RemoveButton_Callback(hObject, eventdata, handles)
currentVal = get(handles.ResultsList,'Value');
resultsStr = get(handles.ResultsList,'String');
numResults = size(resultsStr,1);
% Remove the data and list entry for the selected value
resultsStr(currentVal) =[];
handles.ResultsData(currentVal)=[];
% If there are no other entries, disable the Remove and Plot
button
% and change the list string to <empty>
if isequal(numResults,length(currentVal)),
resultsStr = {'<empty>'};
currentVal = 1;
set([handles.RemoveButton,handles.PlotButton],'Enable','off')
end
% Ensure that list box Value is valid, then reset Value and String
currentVal = min(currentVal,size(resultsStr,1));
set(handles.ResultsList,'Value',currentVal,'String',resultsStr)
% Store the new ResultsData
guidata(hObject, handles)
Plot Results Data
The Plot button callback creates a plot of the run data and adds a legend. The data to
plot is passed to the callback in the handles structure, which also contains the gain
Zobrazit stránku 309
1 2 ... 305 306 307 308 309 310 311 312 313 314 315 ... 499 500

Komentáře k této Příručce

Žádné komentáře