Make a new a directory and save a file in a loop
8 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Kevin Burg
il 23 Lug 2021
Risposto: Image Analyst
il 23 Lug 2021
I am post-processing 36 different cases. What I want to do is run the script, save the variable of interest, create a new directory with the case number, then save the mat file and associated post-processing files in that new directory.
I am running into a problem with the save command. I am getting that I am passing in too many arguments. I'm not sure how I can specify the variable of interest that I am trying to save otherwise though. Any better ways to do this? Thanks for the help!
folder = 'C:Users\me\Documents'
for ind_bet=1:36
run_analysis(); % run script
save_plot_vars; % script to save plotting variables
fullFileName = sprintf('./plotvars_%d/plotvars_%d.mat', ind_bet);
j{ind_bet} = save(fullFileName, 'plotvars'); % plot vars is the variable I want to save
post() % post processing script
cd folder % cd back to original directory and start over
end
0 Commenti
Risposta accettata
Simon Chan
il 23 Lug 2021
use the following for saving data into a file.
save(fullFileName, 'plotvars'); % plot vars is the variable I want to save
0 Commenti
Più risposte (1)
Image Analyst
il 23 Lug 2021
The save() function does not return anything. So you cannot take it's output (of which there is none) and stuff it into j{ind_bet}. Perhaps you really wanted to save filenames???
j{ind_bet} = fullFileName; % Save this filename into a cell array.
save(fullFileName, 'plotvars'); % Don't accept any output arguments when you call save().
0 Commenti
Vedere anche
Categorie
Scopri di più su File Operations in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!