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

1 visualización (últimos 30 días)
Shravan Kumar
Shravan Kumar el 13 de Abr. de 2017
Comentada: Adam el 13 de Abr. de 2017
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.

Respuesta aceptada

Philip G
Philip G el 13 de Abr. de 2017
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 comentarios
Shravan Kumar
Shravan Kumar el 13 de Abr. de 2017
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 el 13 de Abr. de 2017
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.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Images en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by