plot_button_Callback
The plot_button_Callback function executes when the user presses the Plot button.
The callbacks for the Semilogx and Semilogy buttons contain most of the same code.
First, the function calls the local function get_var_names, which returns the two
selected variables in the list.
[x,y] = get_var_names(handles);
Then it checks to make sure at least one variable is selected. If no variables are selected,
the callback returns and does not plot anything.
if isempty(x) && isempty(y)
return
end
Finally, the plot command executes from within the base workspace.
try
evalin('base',['plot(',x,',',y,')'])
catch ex
errordlg(ex.getReport('basic'),...
'Error generating linear plot','modal')
end
The catch block presents an error dialog box if an error occurs.
See Also
Related Examples
- “Create a Simple App Using GUIDE” on page 2-2
- “Write Callbacks in GUIDE” on page 7-2
- “Share Data Among Callbacks” on page 11-2
8 Examples of GUIDE UIs