MATLAB GUIDE入门

可以在MATLAB命令行窗口中输入help guide,然后点击"guide 的参考页",进去后找到"Create a Simple App Using GUIDE"并点击,里面有详细教程。跟着教程走,有以下一些注意事项:

1、
handles.peaks=peaks(35);
handles.brane=membrane;
[x,y] = meshgrid(-8:.5:8);
r = sqrt(x.2+y.2) + eps;
sinc = sin®./r;
handles.sin = sinc;
% Set the current data value.
handles.current_data = handles.peaks;
surf(handles.current_data)
% Choose default command line output for simple_gui
handles.output = hObject;
里面的“handles.peaks”、“handles.brane”、“handles.sin”,handles.后的字符是可以自己任意修改的,如“handles.peaks”可改为”handles.ppppp“.
该处相当于创建一个类成员并赋值。
2、
% Determine the selected data set.
str = get(hObject, ‘String’);
val = get(hObject,‘Value’);
% Set current data to the selected data set.
switch str{val}
case ‘peaks’ % User selects peaks.
handles.current_data = handles.peaks;
case ‘membrane’ % User selects membrane.
handles.current_data = handles.membrane;
case ‘sinc’ % User selects sinc.
handles.current_data = handles.sinc;
end
% Save the handles structure.
guidata(hObject,handles)
case后的字符可跟着String的值更改为中文,,同理后面的handles.peaks也跟着之前更改的字符更改。如:
% Determine the selected data set.
str = get(hObject, ‘String’);
val = get(hObject,‘Value’);
% Set current data to the selected data set.
switch str{val}
case ‘高斯’ % User selects peaks.
handles.current_data = handles.ppppp;
case ‘不知啥’ % User selects membrane.
handles.current_data = handles.brane;
case ‘正弦’ % User selects sinc.
handles.current_data = handles.sin;
end
% Save the handles structure.
guidata(hObject,handles)
该处将当前调用的类成员的值赋给handles.current_data,然后在后面的普通按钮调用。如:
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Display surf plot of the currently selected data.
surf(handles.current_data); %该处调用了当前调用的类成员的值
图例:在这里插入图片描述

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值