How can I save a matlab GUI figure with logo inserted into it.

2 次查看(过去 30 天)
Hi, I have made a simple gui with a calculate button. I just wanted to add a small logo kind to it and make it available as a figure for the end user. I used the following code:
function PV_calculation_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to PV_calculation (see VARARGIN)
% Choose default command line output for PV_calculation
handles.output = hObject;
folder=pwd;
basefilename='logo.jpg';
fullfilename=fullfile(folder,basefilename);
logoimage=imread(fullfilename);
image(logoimage);
axis off;
% Update handles structure
guidata(hObject, handles);
the problem is once I run this code then I will get the image I want but if I save the GUI and open that figure the image is not visible, instead there is only plain axis. Really appreciate the help. I dont know if this is how it is supposed to work or I am missing something with the axes handles.
Thanks in advance.

采纳的回答

Philip G
Philip G 2017-4-13
I do it very similar to your code ...
axes(handles.ax_img) % here I specify the axes where to plot the image
logo1 = imread(['icons' filesep 'logo.png']); % for me the logo is in a subfolder "icons"
image(logo1)
axis off
axis image
And this works fine for me. No command is coming after these lines for the OpeningFcn. I also don't know what you mean with "save the GUI". For me - I created the axis in GUIDE. Saved the .fig file and then added these lines to the .m file.
Hope this helps somehow ...
  7 个评论
Shravan Kumar
Shravan Kumar 2017-4-13
Thanks Adam and Philip. one point got cleared. But even when the .fig, .m and the image are in same folder(i.e document/matlab) I am still seeing the same figure (without the logo). what else could go wrong. sorry for the multiple questions.
Adam
Adam 2017-4-13
Where they are doesn't change the fact that you have to run the program by running the .m, running it from GUIDE itself or calling it on command line or in a function or script.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Interactive Control and Callbacks 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by