MATLAB: Load in multiple text files and store data in a matrix

loopwile e. coyote

I have 28 text files, of this pattern:
out.200.data
out.225.data
up to
out.900.data
How can I populate the 3rd row into a matrix? Note that there are 3 columns in the 3rd row. I also have a path to my files, but for purposes here, let's just say the path is just C:/Path
Is there a way to create a single matrix with these values?
Row 1 of the matrix is the 3rd row of out.200.data
Row 2 of the matrix is the 3rd row of out.225.data
etc?

Best Answer

for information on looping over files.
For any one file, I suggest something like
filename = fullfile(projectdirectory, dinfo(K).name);
fid = fopen(filename, 'rt');
row3(K,:) = cell2mat( textscan(fid, '%f%f%f', 1, 'headerlines', 2, 'collectoutput', true) );
fclose(fid)