User`s guide
10 Examples of GUIDE GUIs
This vector enumerates all the selected row s. If the selection includes less
than 11 rows (as it does h ere) the callback returns, because computing
statistics for a sample that sma ll is not useful.
When the selection contains 11 or more rows, the data table is obtained,
the selection is cached in the
handles structure, and the refreshDisplays
function is called to update the selection statistics and plot, passing the
portion of the table that the user selected:
table = get(hObject,'Data');
handles.currSelection = selecti on;
guidata(hObject,handles)
refreshDisplays(table(selection,:), handles, 2)
Caching the list of row s in the selection is necessary because the user
can force selection data to be replotted by changing plot types. As the
plot_type_Callback has no access to the data table’s event d ata, it requires
a copy of the most recent selection.
Update the Statistics Table and the Graphs
ThecodemustupdatetheDataStatisticstableandthegraphsaboveitwhen:
• The GUI is initialized, in its
tablestat_OpeningFcn.
• The user selects cells in the data table, its
data_table_CellSelectionCallback.
• The u ser selects a different plot type, in the
plot_type_Callback.
In each case, the
refreshDisplays function is called to handle the updates.
It in turn calls two other custom functions:
•
setStats — Computes summary statistics for the selection and returns
them.
•
plotPeriod — Plots the type of graph currently requested in the
appropriate axes.
The
refreshDisplays function identifies the current plot type and specifies
theaxestoplotgraphsinto. Aftercalling
plotPeriod and setStats,it
10-46