下拉菜单Pop-Up Menu的基本用法

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/T_I_A_N_/article/details/85306988

 一、欲实现的功能如下图

二、实现步骤

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

猜你喜欢

转载自blog.csdn.net/T_I_A_N_/article/details/85306988