make GUI to exe file

3 views (last 30 days)
mitra
mitra on 11 Sep 2013
Commented: Image Analyst on 30 Sep 2013
Hi, I create a GUI file in Matlab. It work truly, but when I make it in exe format by 'deploytool". I face a problem. I have .mat file and it is the file which my program add data by "save" and "load", but when it is in exe format, .mat fileremain empty and any add recored is not done.
  3 Comments
Walter Roberson
Walter Roberson on 21 Sep 2013
Could it be an issue with which directory you are writing in? How is the directory chosen?
mitra
mitra on 21 Sep 2013
My code is:
load('MyDatabse')
[r,c] = size(MyDatabse); NewRow = r+1; MyDatabse(NewRow,1) = {handles.val1}; MyDatabse(NewRow,2) = {handles.val2}; MyDatabse(NewRow,3) = {handles.val3}; MyDatabse(NewRow,4) = {handles.val4}; MyDatabse(NewRow,5) = {handles.val5}; MyDatabse(NewRow,6) = {handles.val6}; MyDatabse(NewRow,7) = {handles.val7}; MyDatabse(NewRow,8) = {handles.val8}; MyDatabse(NewRow,9) = {handles.val22}; MyDatabse(NewRow,10) = {handles.val9}; MyDatabse(NewRow,11) = {handles.val10}; MyDatabse(NewRow,12) = {handles.val11}; MyDatabse(NewRow,13) = {handles.val12}; MyDatabse(NewRow,14) = {handles.val13}; MyDatabse(NewRow,15) = {handles.val14}; MyDatabse(NewRow,16) = {handles.val21}; MyDatabse(NewRow,17) = {handles.val15}; MyDatabse(NewRow,18) = {handles.val16}; MyDatabse(NewRow,19) = {handles.val17}; MyDatabse(NewRow,20) = {handles.val18}; MyDatabse(NewRow,21) = {handles.val19}; MyDatabse(NewRow,22) = {handles.val20};
MyDatabse(NewRow,23) = {handles.val23}; MyDatabse(NewRow,24) = {handles.val24};
save('MyDatabse','MyDatabse');

Sign in to comment.

Answers (4)

Image Analyst
Image Analyst on 11 Sep 2013
Call them. I've never experienced that before - where the compilation process, or the installation process, totally empties out a mat file. Sounds very weird so it could be that you are not adding the mat file you think you are, or your code deletes existing mat file and creates a new empty one.

mitra
mitra on 21 Sep 2013
No all things are right. When I run my program in matlab space, it work truely. However, it work bably in .exe format (save comment)
  1 Comment
Image Analyst
Image Analyst on 21 Sep 2013
I don't know what "work bably" means. See the FAQ if your compiled program doesn't work properly. http://matlab.wikia.com/wiki/FAQ#MATLAB_Compiler_Toolbox

Sign in to comment.


Walter Roberson
Walter Roberson on 21 Sep 2013
In an .exe, using
save('MyDatabse','MyDatabse');
means to save the object into whatever directory the executable happens to be in, which by default would be the temporary directory the executable unpacked itself into. The default directory for executables will not be the directory that the user was somehow "in" when the user clicked on the icon to start the program.
See the documentation for ctfroot()
  1 Comment
Image Analyst
Image Analyst on 21 Sep 2013
I think Walter is right. It's a very common blunder for people to not specify the folder for files. So you were probably reading in a .mat file in the same file as your executable, changing it, and writing it out, and then looking at your original file and saw no change but did not realize that the file that got changed was the one in the secret special folder, not the one where the executable was. Did deploytool read in the mat file in the secret folder, and write to the same one or not??? Who knows, so that's why I always make a special effort to specify folders so I KNOW where it's getting the files from and not rely on ctfroot or wherever the current folder happens to be.

Sign in to comment.


mitra
mitra on 30 Sep 2013
Thank you all.
I use below code as our friend said and my program works truly.
pathname = pwd;
baseFileName = 'MyDatabse.mat';
fullFileName = fullFile(pathname, baseFileName);
save(fullFileName, 'MyDatabse');
  1 Comment
Image Analyst
Image Analyst on 30 Sep 2013
Then please mark the answer as "Accepted".

Sign in to comment.

Products

Community Treasure Hunt

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

Start Hunting!