Hi, i have a gui standalone where i load and save data from/to a .mat file. Loading does work with fallowing code...
load(defaultValues.mat)
but saving it with
save(defaultValues.mat)
creats a new .mat file and does not update the original. How can i save to the original .mat file?
There are already some QUESTIONS about this topic put this answer does not work for me...

 Réponse acceptée

Adam
Adam le 12 Nov 2014

0 votes

Use the full path when saving. Otherwise it will dump it in some odd location related to the install directory.

4 commentaires

sejo
sejo le 12 Nov 2014
hi adam, thx for your answer. but as i want to pass my standalone to different users i dont now how to manage to have always the same folder on each user pc...
do you have an idea how to solve that?
Adam's answer is correct, just some additional remarks: "load" will look to the PATH to find the .mat file, whereas save will save to "some odd location". If you want to overwrite, you could do the following:
fileNameWithPath = which('defaultValues.mat');
save(fileNameWithPath);
Titus
Adam
Adam le 12 Nov 2014
Modifié(e) : Adam le 12 Nov 2014
I have set up an environment variable that my compiled applications use and ask the user to give a "Matlab working directory" for which is then used by all my compiled applications that user may install, but Titus' solution is simpler for just updating a given file.
sejo
sejo le 12 Nov 2014
Thx for your help! i will go with the 'simpler solution' as it works fine for me for the default values. for the other values which can be saved i use uigetfile and uiputfile...

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Environment and Settings dans Centre d'aide et File Exchange

Question posée :

le 12 Nov 2014

Commenté :

le 12 Nov 2014

Community Treasure Hunt

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

Start Hunting!

Translated by