simple gui2
显示 更早的评论
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.
% Initialize and hide the GUI as it is being constructed. 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}); %-------add axes------------------------------------------- ha = axes('Units','pixels','Position',[50,60,200,185]); %---------------------------------------------------------- align([hsurf,hmesh,hcontour],'Center','None'); %---------------------------------------------------------- % Create the data to plot peaks_data = peaks(35); membrane_data = membrane; [x,y] = meshgrid(-8:.5:8); r = sqrt(x.^2+y.^2) + eps; sinc_data = sin(r)./r;
% Initialize the GUI.
% Change units to normalized so components resize
% automatically.
set([f,hsurf,hmesh,hcontour],...
'Units','normalized');
%Create a plot in the axes.
current_data = peaks_data;
surf(current_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 visibleb.
set(f,'Visible','on');
%----------------------------------------------------------------
% 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.
surf(current_data);
end
function meshbutton_Callback(source,eventdata)
% Display mesh plot of the currently selected data.
mesh(current_data);
end
function contourbutton_Callback(source,eventdata)
% Display contour plot of the currently selected data.
contour(current_data);
end
end ___________________________________________________________________ This is the edited m file for simple_gui2. I want to change the figure to the figure frommy file which have the directory path as this one,C:\Users\SONY\Documents\MATLAB\a. How can i put this figure into my figure simple_gui2. I want this figure from the file appears as I click the pushbutton. How should i program it?
Thanks
采纳的回答
更多回答(3 个)
bing zeth
2011-3-24
0 个投票
1 个评论
Walter Roberson
2011-3-24
Example:
[filename, pathname] = uigetfile('Choose the input file');
completepath = fullfile(pathname, filename);
data = load(completepath);
fn = fieldnames(data);
current_data = data.(fn{1});
bing zeth
2011-3-28
0 个投票
2 个评论
Walter Roberson
2011-3-28
If you already know the path to the file, then
data = load(completepath);
fn = fieldnames(data);
current_data = data.(fn{1});
bing zeth
2011-4-4
类别
在 帮助中心 和 File Exchange 中查找有关 Graphics Object Properties 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!