Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

make GUI to exe file

Asked by mitra on 11 Sep 2013
Latest activity Commented on by 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

Arthur on 11 Sep 2013

Just to be sure, do you have read/write access to the folder in which the .mat file is stored?

Walter Roberson on 21 Sep 2013

Could it be an issue with which directory you are writing in? How is the directory chosen?

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');

mitra

Products

4 Answers

Answer by 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.

0 Comments

Image Analyst
Answer by 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 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

mitra
Answer by 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 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.

Walter Roberson
Answer by 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 on 30 Sep 2013

Then please mark the answer as "Accepted".

mitra

Contact us