MATLAB: For stand-alone exe, how to include a folder of files and know how to access them.

ctfrootdeploytoolMATLABMATLAB Compilerstand-alone

I have a folder of files I have added to a stand-alone exe. I have been using Desktop->WindowsStandAloneApplication -> Build. There is a link to add files or directories. I have added a folder which has my data files. However, I don't know how to access them. I have tried
if isdeployed
mydir = ctfroot ;
myfile = 'myfile.dat';
fid=fopen([mydir, myfile]);
else
...
end
but it doesn't find the file.

Best Answer

Hi,
everything you add to your project will keep the same folder hierachy. So lets say you have a folder called myfolder and in there a file called myfile.dat. Then you would need to do:
if isdeployed
fid = fopen(fullfile(ctfroot,'myfolder','myfile.dat'))
end
You can also compile once and not embed the CTF. After compilation, open the ctf file in some zip programm and take a look at the folder structure.