Hi everyone,
I have an issue with saving variables. I want to save my variables in a .mat file in a specified folder. Here is my code :
if get(handles.box2,'Value')==1
pexp=mise_en_structure(handlesGUI3);
save(filename,'pexp');
end
movefile('filename','../Données sauvegardées');
guidata(handles.h,handles);
I have this error message :
Error using movefile
No matching files were found.
Error in GUI_Sauvegarder>pb_Callback (line 43)
movefile(filename,'../Données sauvegardées');
Error using waitfor
Error while evaluating uicontrol Callback
Do you have any idea how to solve this? (Except pause(n))
filename is defined like this : (where SpecID is a string)
filename=handles.essais.SpecID{1};
Thanks. Clément

 採用された回答

Orion
Orion 2016 年 4 月 5 日

0 投票

One way to do it .
% name of all files with different extension : toto.m, toto.mat,...
filename = 'toto';
allfiles = dir(pwd);
FilesTomove = {allfiles(strncmp({allfiles.name},filename,length(filename))).name};
for i = 1:length(FilesTomove)
movefile(FilesTomove{i},'../Données sauvegardées');
end
It may be not the "easier" method :)

3 件のコメント

Orion
Orion 2016 年 4 月 5 日
an other way (easier, don't know why I haven't think of that before):
filename = 'toto';
movefile([filename '.*'],'../Données sauvegardées');
Clément P
Clément P 2016 年 4 月 5 日
Ahah yes I found that one too after some research. But I didn't put the '.'.
Here is the code :
filename=handles.essais.SpecID{1}
%save in different extensions depending on user's choices
filename=[filename '*'];
movefile(filename,'./Données sauvegardées');
Thanks!
Orion
Orion 2016 年 4 月 5 日
Be careful, it's not the same.
with '.*', you will get all the files with any kind of extension. toto.m, toto.mat, toto.xls
but with '*' only, you 'll get all the files that begin with your string : toto.m, toto.mat,totofhzerufhzeri.mat,toto2.m,...

サインインしてコメントする。

その他の回答 (2 件)

Orion
Orion 2016 年 4 月 5 日

0 投票

Hi,
you try to move a file named filename
movefile('filename','../Données sauvegardées');
you need something like :
movefile(filename,'../Données sauvegardées');

1 件のコメント

Clément P
Clément P 2016 年 4 月 5 日
Hi,
thanks for answering.
I tried this too. I get the same error message. :/

サインインしてコメントする。

Orion
Orion 2016 年 4 月 5 日

0 投票

I guess it misses the .mat extension in the variable filename.
You need to add it :
change
filename=handles.essais.SpecID{1};
by
filename=[handles.essais.SpecID{1} '.mat'];

1 件のコメント

Clément P
Clément P 2016 年 4 月 5 日
Yes i just found out that too. Is there a way to get all files named 'filename' without taking into account the extension?
I have multiple extensions possible, depending on user's choices.

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeFile Operations についてさらに検索

質問済み:

2016 年 4 月 5 日

コメント済み:

2016 年 4 月 5 日

Community Treasure Hunt

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

Start Hunting!

Translated by