From: Paul on
If I am using a loop to load several data files, each of which consist of a 100x3 matrix, can I assign each matrix as part of an array?

files=dir('input*')
for i=1:length(files)
data=load(files(i).name);
end

is what I have, but if I cannot change data to data(i) in an attempt to assign each matrix as it loops.

Any ideas on the proper way to do this? Thanks!
From: Walter Roberson on
Paul wrote:
> If I am using a loop to load several data files, each of which consist
> of a 100x3 matrix, can I assign each matrix as part of an array?
>
> files=dir('input*')
> for i=1:length(files)
> data=load(files(i).name);
> end
>
> is what I have, but if I cannot change data to data(i) in an attempt to
> assign each matrix as it loops.
>
> Any ideas on the proper way to do this? Thanks!

Cell arrays.

numfiles = length(files);
data = cell(numfiles,1);
for i = 1 : numfiles
data{i} = load(files(i).name);
end