用matlab添加listbox控件
修改string和value值,value为几就对应第几行字符串
添加button按钮,将string值改为“选择x轴参数”,字体大小为10
再添加一个按钮,将string值修改为:选择y按钮,字体大小为10
再添加两个edittext控件,string设空
为按钮添加callback定义动作
在listbox回调函数中定义参数
t=0:0.01:2*pi;
canshu1=t;
canshu2=sin(t);
canshu3=cos(t);
canshu4=sin(t)+cos(t);
将参数保存在矩阵中
CS={canshu1,canshu2,canshu3,canshu4};
handles.CS=CS; %将具体数值保存在此
用guidata来更新结构体
guidata(hObject,handles);
获得具体参数的数值,当选x参数时
selected.index=get(handles.listbox1,'value');
str=get(handles.listbox1,'string');
set(handles.edit1,'string',str{selected.index})
x=handles.CS{selected.index};
handles.x=x;
duidata(hObject,handles)
同理,获得具体参数的数值,当选y参数时
selected.index=get(handles.listbox1,'value');
str=get(handles.listbox1,'string');
set(handles.edit2,'string',str{selected.index})
y=handles.CS{selected.index};
handles.y=y;
duidata(hObject,handles)
然后添加按钮和坐标系
对button3创建响应函数
并添加如下
axes(handles.axes1);
plot(handles.x,handles.y)
axes equal
调试运行,查看x,y轴选择不同参数时的曲线