How to dynamically generate a file name from a cell array?

Hi All,
I'm pretty new to MATLAB so sorry for any vocabulary abuses. I am trying to write a script which dynamically generates file names from the values of a cell array (all text). But I can't seem to find a way to code in the selection of a variable into a save command. Everything I've tried reads the variable as text.
Here is my code: savename=Filenames(1)
savename =
'CRM 114 Bottle 1183-pre CV1 ALK3'
How do I generate a text file with the name "CRM 114 Bottle 1183-pre CV1 ALK3" instead of "savename"?
Thanks so much for the assistance.

 採用された回答

Walter Roberson
Walter Roberson 2011 年 12 月 5 日

0 投票

savename = Filenames{1};
save(savename, '-ascii')

2 件のコメント

David
David 2011 年 12 月 5 日
Hi Walter,
Thanks for the quick response.
Unfortunately, I got this error message when I tried it.
??? Error using ==> save
Argument must contain a string.
Any ideas?
D
David
David 2011 年 12 月 5 日
sorry i missed the {} and used () instead. it works fine now. thanks.

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeEnvironment and Settings についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by