How can I save a matlab GUI figure with logo inserted into it.
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Shravan Kumar
am 13 Apr. 2017
Kommentiert: Adam
am 13 Apr. 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.
0 Kommentare
Akzeptierte Antwort
Philip G
am 13 Apr. 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 Kommentare
Adam
am 13 Apr. 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.
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!