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

조회 수: 1 (최근 30일)
Shravan Kumar
Shravan Kumar 2017년 4월 13일
댓글: Adam 2017년 4월 13일
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에서 Images에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by