User`s guide
10 Examples of GUIDE GUIs
• Creates a structure to save the results of the simulation, the current
values of the simulation parameters set by the GUI, and the run name
and number.
• Stores the structure in the
handles structure.
• Updates the list box
String to list the most recent run.
Here is the Simulate and store results button callback:
function Simula teBu tton_Callback(hObject, eventdata, handles)
[timeVector,stateVector,outputVecto r] = sim('f14');
% Retrieve old results data structure
if isfield(h andl es,'ResultsData') &
~isempty(handles.ResultsData)
ResultsData = handles.ResultsData;
% Determine the maximum run number currently used.
maxNum = ResultsData(length(Result sData)).RunNumber;
ResultNum = maxNum+1;
else % Set up the results data structure
ResultsData = struct('RunName',[],'RunNumber',[],...
'KiValue',[],'KfValue',[],'timeVector ',[],...
'outputVector',[]);
ResultNum = 1;
end
if isequal(R esul tNum,1),
% Enable the Plot and Remove buttons
set([handles.RemoveButton,handles.Plot Button],'Enable','on')
end
% Get Ki and Kf values to store with the data and put in the
results list .
Ki = get(handles.KiValueSlider, 'Value');
Kf = get(handles.KfValueSlider, 'Value');
ResultsData(ResultNum).RunName = ['Run',num2str(Result Num)];
ResultsData(ResultNum).RunNumber = ResultNum;
ResultsData(ResultNum).KiValue = Ki;
ResultsData(ResultNum).KfValue = Kf;
ResultsData(ResultNum).timeVector = timeVector;
ResultsData(ResultNum).outputVector = outputVector;
% Build the new results lis t string for the listbox
ResultsStr = get(handles.ResultsList,'String');
10-74