什么是matlab gui
来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/05/22 08:33:25
什么是matlab gui
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.
clc
f = 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);
end
end
% 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.
clc
f = 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);
end
end
什么是matlab gui
MATLAB中GUI界面显示结果图
谁能解释下MATLAB GUI里这句话是什么意思?
怎么用MATLAB做个简单的GUI?
请问参加数学建模比赛是否需要学matlab GUI
MATLAB的gui中全局变量在哪里定义
求一个matlab画任意函数图像的GUI实例,例如下面的
什么是matlab神经网络
gui gui字怎么写
求 基于matlab 的 f.i.r滤波器 频率抽样法的 gui设计?尽快,分高,能者速来
MATLAB GUI的问题,下面是关于JK触发器的时钟信号的编程,如何使轴间距变为0.5,即0.5发生一次变化?
matlab 线性函数的拟合 不要用toolsbox 和 GUI,拟合两组数据X和Y,分别拟合Y=a*X+b和y=ax^