Automated process to save outputs into various MAT files

1 vue (au cours des 30 derniers jours)
Karthik Nagaraj
Karthik Nagaraj le 20 Fév 2020
Commenté : Karthik Nagaraj le 28 Fév 2020
I have numerous covariance matrixes as output from deep neural network and that needs to be stored into various MAT files appending the date and time to the filename. I want to automate the process to save these outputs into various MAT files in a folder.

Réponses (1)

Walter Roberson
Walter Roberson le 22 Fév 2020
char(datetime('now', 'format', FORMAT_YOU_WANT))
strcat that with the base file name, fullfile() the directory into place, use that as the first parameter to save() with the remaining parameters being the names of the variables to save, expressed as character vectors.
  1 commentaire
Karthik Nagaraj
Karthik Nagaraj le 28 Fév 2020
Thank you for response and sorry for my delayed response. I could almost get the idea what you explained, but still have some problems to get the necessary output.
Instead of Cov mat output, I have used a loop for creating magic matrices and store that in a cell here.Then I need to save the indivdual magic matrices as a separate mat file in a specific folder and with filenames in ddmmyss.mat format
n=4;
M=cell(n,1)
f = fullfile('c:\','myfiles','matlab',filesep)
t = datetime('now','Format','dMMyHHmmss')
ct=char(t)
st=strcat(f,ct)
for j = 1:n
M{j} =magic(j) ;
data = M{j};
fnm = sprintf('file_%d.mat',j);
fnm1= sprintf('file_%s.mat',st);
save(fnm,'data');
save(fnm1,'data');
end
In the above code I can save fnm but not the fnm1. I am getting an error
Error using save
Unable to open file "file_c:\myfiles\matlab\28022020115627.mat" for output.
Can you help me the requirment. Thanks

Connectez-vous pour commenter.

Catégories

En savoir plus sur Data Import and Analysis dans Help Center et File Exchange

Tags

Produits


Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by