Can I pre-set save-filename, just like in C?

1 回表示 (過去 30 日間)
smo
smo 2016 年 4 月 18 日
コメント済み: smo 2016 年 4 月 19 日
Hi, I am wondering, in Matlab, can I preset a file name?
for example say, I am dealing with 100 data sets. Each of them will go through a long Matlab program and then I want to save the output vector in a file (1 set gives 1 file, aka, 100 output files at the end). But as I don't want to change the data-set file name at the beginning of the program, and then change save-file name at the bottom of the program for 100times, I want to do something like:
*********************
datafile = 01.dat;
AA = output_01.dat;
.
(main program)
.
save AA variable -ascii
*********************
So each time I only need to change the name of 'datafile' and the name of 'AA' at the beginning of the program. Is it possible to do this in Matlab?
Thanks.

採用された回答

James Tursa
James Tursa 2016 年 4 月 18 日
編集済み: James Tursa 2016 年 4 月 19 日
Do you mean something like this?
datafile = '01.dat';
AA = ['output_' datafile]; % <-- Concatenate your root name with the ending
:
save(AA,'variable','-ascii');
  3 件のコメント
James Tursa
James Tursa 2016 年 4 月 19 日
See my edited answer.
smo
smo 2016 年 4 月 19 日
Thank you very much!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeWorkspace Variables and MAT-Files についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by