CAD教程 行业资讯 3D模型下载 Pro/E教程 CAD书店 软件下载 联系我们
技术资料 CAD招聘 发布招聘 CAD问答 设计竞赛 CAD认证 北京CAD培训
视频教程 PS教程 CAD图纸 图书推荐 Solidworks教程 CAD培训 CAD软件商

 最新视频教程Pro/ENGINEER Wildfire2.0 工业设计实例视频教程 (全套免费在线学习)   AutoCAD视频教程每日更新
 
首页 > CAD在线问答 > matlab

MATLAB GUI

2010-10-09 51自学网



可不可以在一个axes里轮流呈现多个图形,假如运行GUI程序后,首先呈现在里面的是第一个波形,然后用按钮或其它方式再依次呈现其它特征波形呢?希望大虾能帮帮我

这是非常基本的问题,请看matlab提供的gui帮助文件吧。 下面是matlab帮助里面的一个用纯代码生成GUI的例子,有你需要的类似功能。本来其数据共享是采用嵌套函数的,但在6.5版本下好像不行,我改成用guidata函数进行存取数据的方式了,供你运行参考。看起来代码很长,其实并不难的,但愿对你有帮助,O(∩_∩)O~。function simple_gui2% SIMPLE_GUI2 Select a data set from the pop-up menu, then% click one of the plot-type push buttons. Clicking the button% plots the selected data in the axes.% Create and then hide the GUI as it is being constructed.clcf = figure('Visible','off','Position',[360,500,450,285]);% Construct the components.hsurf = uicontrol('Style','pushbutton','String','Surf',... 'Position',[315,220,70,25],... 'Callback',{@surfbutton_Callback});hmesh = uicontrol('Style','pushbutton','String','Mesh',... 'Position',[315,180,70,25],... 'Callback',{@meshbutton_Callback});hcontour = uicontrol('Style','pushbutton',... 'String','Countour',... 'Position',[315,135,70,25],... 'Callback',{@contourbutton_Callback});htext = uicontrol('Style','text','String','Select Data',... 'Position',[325,90,60,15]);hpopup = uicontrol('Style','popupmenu',... 'String',{'Peaks','Membrane','Sinc'},... 'Position',[300,50,100,25],... 'Callback',{@popup_menu_Callback});ha = axes('Units','Pixels','Position',[50,60,200,185]);align([hsurf,hmesh,hcontour,htext,hpopup],'Center','None');% Create the data to plot.data.peaks_data = peaks(35);data.membrane_data = membrane;[x,y] = meshgrid(-8:.5:8);r = sqrt(x.^2+y.^2) + eps;data.sinc_data = sin(r)./r;% Initialize the GUI.% Change units to normalized so components resize% automatically.set([f,ha,hsurf,hmesh,hcontour,htext,hpopup],...'Units','normalized');%Create a plot in the axes.data.current_data = data.peaks_data;surf(data.current_data);guidata(f,data);% Assign the GUI a name to appear in the window title.set(f,'Name','Simple GUI')% Move the GUI to the center of the screen.movegui(f,'center')% Make the GUI visible.set(f,'Visible','on');% Callbacks for simple_gui2. These callbacks automatically% have access to component handles and initialized data% because they are nested at a lower level.% Pop-up menu callback. Read the pop-up menu Value property% to determine which item is currently displayed and make it% the current data. function popup_menu_Callback(source,eventdata) % Determine the selected data set. str = get(source, 'String'); val = get(source,'Value'); % Set current data to the selected data set. data=guidata(source); switch str{val}; case 'Peaks' % User selects Peaks. data.current_data = data.peaks_data; case 'Membrane' % User selects Membrane. data.current_data = data.membrane_data; case 'Sinc' % User selects Sinc. data.current_data = data.sinc_data; end guidata(source,data)% save the change of data.current_data end% Push button callbacks. Each callback plots current_data in% the specified plot type. function surfbutton_Callback(source,eventdata) % Display surf plot of the currently selected data. data=guidata(source); surf(data.current_data); end function meshbutton_Callback(source,eventdata)% Display mesh plot of the currently selected data. data=guidata(source); mesh(data.current_data); end function contourbutton_Callback(source,eventdata)% Display contour plot of the currently selected data. data=guidata(source); contour(data.current_data); endend



 

 

matlab for程序编写
为什么我安装的MATLAB7。0
我来回答 共有条 回答
用户名: 密码:
验证码: 匿名发表
| AutoCAD | Pro/E | UG | 3Dmax | catia | solidworks | maya | photoshop | 模具设计 | 有限元 | matlab | 计算机图形学 | 室内设计 |