I have to use for the first time a popup menu in a GUI interface. I know I can switch two or more options with it; for example, if 'plot1' and 'plot2' are the two cases, I can decide which one I want to plot, with this function:
function popupmenu1_Callback(hObject, eventdata, handles)str = get(hObject, 'String');val = get(hObject,'Value');% Set current data to the selected data set.
switch str{val};case 'plot1'axes(handles.plot)plot(x1,y1);case 'plot2'axes(handles.plot)plot(x2,y2);endguidata(hObject,handles)
but what if I want to use a push button whose action depends on the string appearing in the popup menu? For example, if I have a pushbutton 'Linear fit' whose callback function makes a linear fit of the plot, how can I distinguish here the two cases of the popup menu? Thanks
Best Answer