MATLAB: Read 1000’s .csv files and concatenate them

csvread

Hi, I am trying to read 1760 .csv files and concatenate them. I have 2500 entries in each .csv I could do each one individually and then concatenate them at the end, but there has to be a more efficient way to do this.
This is my code so far:
for i = 1:1760
Tds(:,i) = csvread(strcat('d0.',num2str(i-1),'.csv'),2);
end
I need to skip the first row of data, and I get the following error when I run that code:
Assignment has more non-singleton rhs dimensions than non-singleton subscripts
Any suggestions?

Best Answer

N = 1760;
C = cell(1,N);
for k = 1:N
F = sprintf('d0.%d.csv',k-1);
C{k} = csvread(F,2);
end
and after that either vertcat or horzcat:
M = horzcat(C{:})
M = vertcat(C{:})
Alternatively you could preallocate a numeric array of the correct size:
N = 1760;
M = nan(2500,N);
for k = 1:N
F = sprintf('d0.%d.csv',k-1);
M(:,k) = csvread(F,2);
end