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

 Akzeptierte Antwort

Henrik
Henrik am 7 Dez. 2014

0 Stimmen

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 Kommentare

Eric
Eric am 7 Dez. 2014
Bearbeitet: Image Analyst am 7 Dez. 2014
I'm sorry about that. I'm asking whether it's possible to change the input name after loading a file. If I loaded a file containing multiple matrices and I want a loop to extract specific parts of information:
% load('test1.mat'); and load('test2.mat') => each one containing numb_val and numb_non
names = {'numb_val', 'numb_non'}
for ii = 1: names
load('test1');
new_val = names(ii);
load('test2');
new_val = names(ii);
end
The question being how I can change the input names in front of new_val.
Best regards,
Christian
Image Analyst
Image Analyst am 7 Dez. 2014
Bearbeitet: Image Analyst am 7 Dez. 2014
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 am 7 Dez. 2014
I'm very sorry about that Image Analyst.
And thank you for the response Henrik.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Image Processing and Computer Vision finden Sie in Hilfe-Center und File Exchange

Tags

Gefragt:

am 7 Dez. 2014

Bearbeitet:

am 7 Dez. 2014

Community Treasure Hunt

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

Start Hunting!

Translated by