MATLAB Answers

Change input name when running a script

2 views (last 30 days)
Eric
Eric on 7 Dec 2014
Edited: Image Analyst on 7 Dec 2014
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

Accepted Answer

Henrik
Henrik on 7 Dec 2014
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 Comments
Eric
Eric on 7 Dec 2014
I'm very sorry about that Image Analyst.
And thank you for the response Henrik.

Sign in to comment.

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by