Constructing saved file name with variables from code

Hi all
I currently have a save command which labels the saved files with a static name which I change each time
If I have variables such as:
k = 1:10
I= 1:5:100
Date/Time
How can I code this so each file name takes this information for the name,
i.e something like
Test_File %datestr(now,30) plus the others.
Thanks for your help!

回答 (2 件)

Renato Agurto
Renato Agurto 2016 年 3 月 17 日

0 投票

Do you meansomething like this?
ext = '.mat'; %or .cvs, .xlsx, ...
file_name = ['Test_File_' datestr(now,30) '_' num2str(k) '_' num2str(I) ext];
Guillaume
Guillaume 2016 年 3 月 17 日

0 投票

I would recommend you use sprintf:
filename = sprintf('Test_File_%s_%d_%d.mat', datestr(now, 30), k, i);

カテゴリ

ヘルプ センター および File ExchangeWorkspace Variables and MAT Files についてさらに検索

質問済み:

Om
2016 年 3 月 17 日

回答済み:

2016 年 3 月 17 日

Community Treasure Hunt

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

Start Hunting!

Translated by