Adam893
Adam893

Reputation: 143

Read multiple .mat files and store them in a cell

Previous .mat file reading questions have been looked at, this is a little more specific so please bear with me.

I have a large dataset of files named:

int_f0270.mat
int_f0271.mat
...

These are image matrices that I need to read into MATLAB so that I can perform sequential operations on them. The code I am using is below:

   for i = 270:273
   filename = strcat('int_f0',int2str(i),'.mat');
   load(filename);
   end

This works for the first file (e.g. int_f0271.mat), but fails to load any more .mat files into picture.

The only output I get is this:

enter image description here

which is the correct size and can be displayed as an image but I need this for all my data set. Any help would be greatly appreciated.

Upvotes: 0

Views: 135

Answers (1)

Rash
Rash

Reputation: 4336

ImageCell = {};
for i = 270:273
filename = strcat('int_f0',int2str(i),'.mat');
load(filename);
ImageCell{i-269} = C;
clear C
end

Upvotes: 2

Related Questions