| Creating Graphical User Interfaces |     ![]()  | 
Plotting the Results Data
The GUI 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 settings in use when the simulation ran. When a user clicks on the Plot button, the callback executes the following steps.
Plotting Into the Hidden Figure
The figure that contains the plot is created invisible and then made visible once the plot and legend have been created. To prevent this figure from becoming the target of plotting commands issued at the command line or by other GUIs, its HandleVisibility and IntegerHandle properties are set to off. However, this means the figure is also hidden from the plot and legend commands. 
Use the following steps to plot into a hidden figure:
Parent property to the figure handle, and save the axes handle. Parent properties to the handle of the axes.Plot Button Callback Listing
The following code is the Plot button callback.
function varargout = PlotButton_Callback(h, eventdata, handles, varargin) currentVal = get(handles.ResultsList,'Value');% Get data to plot and generate command string with color specifiedlegendStr = cell(length(currentVal),1); plotColor = {'b','g','r','c','m','y','k'}; for ctVal = 1:length(currentVal); PlotData{(ctVal*3)-2} = handles.ResultsData(currentVal(ctVal)).timeVector; PlotData{(ctVal*3)-1} = handles.ResultsData(currentVal(ctVal)).outputVector; numColor = ctVal - 7*( floor((ctVal-1)/7) ); PlotData{ctVal*3} = plotColor{numColor}; legendStr{ctVal} = [handles.ResultsData(currentVal(ctVal)).RunName,... '; Kf=', ... num2str(handles.ResultsData(currentVal(ctVal)).KfValue),... '; Ki=', ... num2str(handles.ResultsData(currentVal(ctVal)).KiValue)]; end% If necessary, create the plot figure and store in handles structureif ~isfield(handles,'PlotFigure') | ~ishandle(handles.PlotFigure), handles.PlotFigure = figure('Name','F14 Simulation Output',... 'Visible','off','NumberTitle','off',... 'HandleVisibility','off','IntegerHandle','off'); handles.PlotAxes = axes('Parent',handles.PlotFigure); guidata(h,handles) end% Plot datapHandles = plot(PlotData{:},'Parent',handles.PlotAxes);% Add a legend, and bring figure to the frontlegend(pHandles(1:2:end),legendStr{:})% Make the figure visible and bring it forwardfigure(handles.PlotFigure)
   | Removing Results from the List Box | The GUI Help Button | ![]()  |