simple gui2
Show older comments
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
Accepted Answer
More Answers (3)
bing zeth
on 24 Mar 2011
0 votes
1 Comment
Walter Roberson
on 24 Mar 2011
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
on 28 Mar 2011
0 votes
2 Comments
Walter Roberson
on 28 Mar 2011
If you already know the path to the file, then
data = load(completepath);
fn = fieldnames(data);
current_data = data.(fn{1});
bing zeth
on 4 Apr 2011
bing zeth
on 4 Apr 2011
0 votes
Categories
Find more on Graphics Object Properties in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!