フィルターのクリア

how to save dynamic file name

5 ビュー (過去 30 日間)
Mos_bad
Mos_bad 2018 年 3 月 27 日
編集済み: Stephen23 2018 年 3 月 27 日
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');

採用された回答

Rik
Rik 2018 年 3 月 27 日
編集済み: Rik 2018 年 3 月 27 日
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');

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSearch Path についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by