Old Nick
Advanced Member level 1
matlab load multiple files
I have created several hundred text files of data (64x64 arrays). I need to load them into matlab (preferably into a 3D array - of 64x64xnumbefOfFiles.).
The file names of the data are incremantal, i.e. file_1, file_2 etc.
I am hoping there is a way of doing this with a loop.
And would it be possible to create a similar array from part of the files, it is only around 100 elements in the middle of each file that I am interested in comparing.
Cheers for any help,
Nick
Added after 1 hours 14 minutes:
I've managed to work it out, well the first part anyway.
I would still like to know if it's possible to load part of a file(array of numbers) in such a way.
Cheers,
Nick
I have created several hundred text files of data (64x64 arrays). I need to load them into matlab (preferably into a 3D array - of 64x64xnumbefOfFiles.).
The file names of the data are incremantal, i.e. file_1, file_2 etc.
I am hoping there is a way of doing this with a loop.
And would it be possible to create a similar array from part of the files, it is only around 100 elements in the middle of each file that I am interested in comparing.
Cheers for any help,
Nick
Added after 1 hours 14 minutes:
I've managed to work it out, well the first part anyway.
Code:
firstFile = 1;
lastFile = 5;
nSamples = 10;
columns = 2;
for n = firstFile : 1 : lastFile
number = num2str( n );
file = strcat('file',number,'.dat');
stored(:,:,n) = load( file );
end
I would still like to know if it's possible to load part of a file(array of numbers) in such a way.
Cheers,
Nick