Change input name when running a script

1 回表示 (過去 30 日間)
Eric
Eric 2014 年 12 月 7 日
編集済み: Image Analyst 2014 年 12 月 7 日
Hi everybody,
I'm trying to change the input name but I can't get it to work. Basically, what I want to do is changing the autoname below for each run:
load('test1.mat');
load('test2.mat');
names = {'test1', 'test2'};
for autoname = 1:length(names)
All_numbs=autoname;
end
So it ends up being different matrices called at each iteration.
Thanks in advance.
Best regards,
Christian

採用された回答

Henrik
Henrik 2014 年 12 月 7 日
I'm not sure what you're asking, but does this help?
names={'test1', 'test2'};
for k=1:length(names)
autoname=names{k};
load(autoname);
% or you can do load(['names{k} '.mat']);
end
  3 件のコメント
Image Analyst
Image Analyst 2014 年 12 月 7 日
編集済み: Image Analyst 2014 年 12 月 7 日
I formatted your code, again. Please read this
I don't understand what you're doing. Why didn't you do what Henrik suggested? That will let you specify a filename using an index from a predefined list of filenames.
Eric
Eric 2014 年 12 月 7 日
I'm very sorry about that Image Analyst.
And thank you for the response Henrik.

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

その他の回答 (1 件)

Image Analyst
Image Analyst 2014 年 12 月 7 日

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by