Matlab界面设计入门
2015-09-03 16:41
645 查看
1.文本编辑框+按钮
pushbutton的callback代码:
2.滚动条显示值
滚动条后台callback代码(实践由滚动条产生触发):
3.单选框+复选框+togglebutton简单示例
三个控件的后台callback:
4.选择描绘不同三角函数曲线
将三个radio button放在一个button group中。
buttonGroup的后台SelectionChangeFcn:
5.下拉选择功能菜单
pop up menu的callback代码:
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 slider var=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 rb var=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 tb var=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-2pi current_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 ppm var=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
相关文章推荐
- 分享下手机软件界面设计浅析
- 解析在main函数之前调用函数以及对设计的作用详解
- java和matlab画多边形闭合折线图示例讲解
- C#调用Matlab生成的dll方法的详细说明
- 从java中调用matlab详细介绍
- [Android]继承式UI界面布局设计
- VC++与Matlab混合编程的快速实现
- SQLite可视化管理工具汇总
- Matlab 矩阵运算
- matlab与opencv部分函数的对照
- [网站美工必读]网页设计理念
- 谁说谷歌没品味?搜索巨人开始狠抓界面设计
- C/C++ 开发环境配置(GTK/GNOME/Qt/KDE)
- 黑暗模式:那些骗人的界面设计!
- matlab神经网络工具箱创建神经网络
- Matlab
- MATLAB 入门教程
- Android ViewPager多页面滑动切换以及动画效果
- matlab函数_连通区域
- java 学习笔记---布局管理组件