下拉選單Pop-Up Menu的基本用法
阿新 • • 發佈:2019-01-06
一、欲實現的功能如下圖
二、實現步驟
2.1、需要用到Pop-Up Menu和座標軸控制元件,修改Pop-Up Menu的value值
value=1,對應sin(x),以此類推。
2.2、進入回撥函式
function p1_Callback(hObject, eventdata, handles) % hObject handle to p1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: contents = cellstr(get(hObject,'String')) returns p1 contents as cell array % contents{get(hObject,'Value')} returns selected item from p1 var=get(handles.p1,'value'); x=0:0.01:2*pi; axes(handles.axes1); switch var case 1 y=sin(x); plot(x,y); case 2 y=cos(x); plot(x,y); case 3 y=sin(x)+cos(x); plot(x,y); end