MATLAB Creating Graphical User Interfaces

(ff) #1

plot_type_Callback


The plot_type_Callback function executes when the user changes the selection in the
pop-up menu at the top of the window. The following statements get the currently
selected menu item and update the label above the axes.


index = get(hObject,'Value');
strlist = get(hObject,'String');
set(handles.uipanel3,'Title',strlist(index))


These commands get all 288 entries in the table and plot them in the top axes. The
refreshDisplays function is a locally defined function.


table = get(handles.data_table,'Data');
refreshDisplays(table, handles, 1);


These commands update the bottom plot and the statistical summary table if more than
10 entries are selected.


selection = handles.currSelection;
if length(selection) > 10
refreshDisplays(table(selection,:), handles, 2)
else
% Do nothing; insufficient observations for statistics
end


data_table_CellSelectionCallback


The data_table_CellSelectionCallback function executes when the user selects
any of the cells in the larger table on the left. This command gets the currently selected
entries in the table:


selection = eventdata.Indices(:,1);


These commands update the currSelection field of the handles structure so that the
user’s selection can be accessed from within other callbacks such as the
plot_type_Callback function.


handles.currSelection = selection;
guidata(hObject,handles);


Finally, refreshDisplays updates the bottom plot and the statistical summary table.


refreshDisplays(table(selection,:),handles,2);


GUIDE App Containing Tables and Plots
Free download pdf