This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.

GUIDE App Containing Tables and Plots

This example shows how to examine and run a prebuilt GUIDE app. The app contains two tables, two axes, and a pop-up menu. The larger table on the left displays 288 entries of sunspot data. The top axes displays the graph of all 288 entries. When you select 11 or more items from the table on the left, the graph of the selected entries displays in the bottom axes. The table in the lower right corner displays a statistical summary of the sunspot data. The pop-up menu at the top of the window allows you to toggle between graphs in the time and frequency domains.

Open and Run the Example

To open the example in GUIDE, click the Open Script button on this page. To run the app, click the green Run Figure button at the top of the GUIDE window.

Select 11 or more rows in the Data Set table to see a plot of those points on the bottom set of axes. As you modify your selection, the numbers in the second column of the Data Statistics table update.

Examine the Code

  1. In GUIDE, click the Editor button to view the code.

  2. Near the top of the Editor window, use the Go To button to navigate to the functions discussed below.


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');

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)
    % Do nothing; insufficient observations for statistics


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;

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


Related Examples

Was this topic helpful?