Azzera filtri
Azzera filtri

how to save dynamic file name

5 visualizzazioni (ultimi 30 giorni)
Mos_bad
Mos_bad il 27 Mar 2018
Modificato: Stephen23 il 27 Mar 2018
I want to save Force_y data as Force.mat in the directory of ./Output/THOutput/LHS(i)/GMID(k) where i and k are dynamic indices. I have written the following code but it did not work. Note the saved file name would be Force.mat
fname = sprintf('./Output/THOutput/LHS%d/GMID%dForce.mat', i,k);
save ('fname', 'Force_y');

Risposta accettata

Rik
Rik il 27 Mar 2018
Modificato: Rik il 27 Mar 2018
You shouldn't pass fname as a string, but as a variable:
fname = sprintf('./Output/THOutput/LHS%d/GMID%dForce.mat', i,k);
save(fname,'Force_y');
And don't you want GMID(k) to be a directory? In that case you should add another filesep:
fname = sprintf('./Output/THOutput/LHS%d/GMID%d/Force.mat', i,k);
save(fname,'Force_y');

Più risposte (0)

Categorie

Scopri di più su Search Path in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by