Matlab界面设计入门
来源:互联网 发布:专业电脑视频剪辑软件 编辑:程序博客网 时间:2024/04/27 21:38
1.文本编辑框+按钮
pushbutton的callback代码:
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)str=get(handles.edit1,'String');set(handles.edit2,'String',str);
2.滚动条显示值
滚动条后台callback代码(实践由滚动条产生触发):
function slider1_Callback(hObject, eventdata, handles)% hObject handle to slider1 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hints: get(hObject,'Value') returns position of slider% get(hObject,'Min') and get(hObject,'Max') to determine range of slidervar=get(handles.slider1,'value');%value 属性哦set(handles.edit1,'String',num2str(var));
3.单选框+复选框+togglebutton简单示例
三个控件的后台callback:
function rb_Callback(hObject, eventdata, handles)% hObject handle to rb (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hint: get(hObject,'Value') returns toggle state of rbvar=get(handles.rb,'value');set(handles.edit1,'string',num2str(var));% --- Executes on button press in ck.function ck_Callback(hObject, eventdata, handles)% hObject handle to ck (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)var=get(handles.ck,'value');set(handles.edit2,'string',num2str(var));% Hint: get(hObject,'Value') returns toggle state of ck% --- Executes on button press in tb.function tb_Callback(hObject, eventdata, handles)% hObject handle to tb (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hint: get(hObject,'Value') returns toggle state of tbvar=get(handles.tb,'value');set(handles.edit3,'string',num2str(var));
4.选择描绘不同三角函数曲线
将三个radio button放在一个button group中。
buttonGroup的后台SelectionChangeFcn:
function uipanel1_SelectionChangeFcn(hObject, eventdata, handles)% hObject handle to the selected object in uipanel1 % eventdata structure with the following fields (see UIBUTTONGROUP)% EventName: string 'SelectionChanged' (read only)% OldValue: handle of the previously selected object or empty if none was selected% NewValue: handle of the currently selected object% handles structure with handles and user data (see GUIDATA)x=0:0.01:2*pi;%x轴的范围0-2picurrent_Obj=get(eventdata.NewValue,'Tag');axes(handles.axes1);switch current_Obj case 'rb1' y=sin(x); plot(x,y); case 'rb2' y=cos(x); plot(x,y); case 'rb3' y=sin(x)+cos(x); plot(x,y);end
5.下拉选择功能菜单
pop up menu的callback代码:
function ppm_Callback(hObject, eventdata, handles)% hObject handle to ppm (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 ppm contents as cell array% contents{get(hObject,'Value')} returns selected item from ppmvar=get(handles.ppm,'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
0 0
- Matlab界面设计入门
- matlab界面设计---对话框设计
- matlab GUI界面设计总结
- Matlab GUI界面设计
- Android入门之界面设计
- MFC界面设计入门篇
- matlab界面设计之一 二维绘图
- Matlab GUI 界面设计基础(1)
- MatLab 入门
- MATLAB入门
- matlab 入门
- MATLAB入门
- matlab入门
- Matlab入门
- Matlab入门
- Matlab入门
- matlab入门
- Matlab入门
- Unity3d使用UGUI实现长按功能
- PHP中的错误与异常
- Packets(模拟 POJ1017)
- 【白书之路】340 - Master-Mind Hints 数字统计
- 图论:拓扑排序
- Matlab界面设计入门
- Windows下Nginx的安装与配置
- How to deploy iOS apps to the iPhone via the command line
- android 布局
- morose things go by
- 操作符重载[ ];
- Unity3D学习笔记《Space Shooter》二
- mezzanine timezone 的问题
- socket通信之八:完成端口模型实现的客户/服务器模型