I have a GUI and with an image. The GUI opens with a message box and then open the main GUI were I have an handles.axesGUI showing the image. As I compile the code how can I make the image location folder the same as the location of the compiled code (which can be changed in every computer)?
% --- Executes just before DiaCurvBeta0_6 is made visible.
function Testz_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 DiaCurvBeta0_6 (see VARARGIN)
set(handles.infoTable, 'data',[]);
% Choose default command line output for DiaCurvBeta0_6
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
hMsg=msgbox({'TEST'} ,'About','modal');
Children = get(hMsg,'Children');
OKButton = Children(1);
set(OKButton,'BackgroundColor',[0.8 0.8 0.8])
uiwait(hMsg)
imshow('E:/CC.png','Parent',handles.axesGUI)
In your function, you can use mfilename
to determine the path of your function:
f = mfilename('fullpath');
f = fileparts(f);
f = fullfile(f,'CC.png');
imshow(f,'Parent',handles.axesGUI)
...assuming CC.png
is a file next to your M-file. In the MATLAB Compiler you can specify that you want this resource file included in the deployed package.