conactenate using a loop



Dear all,

I would like to concatenate various matrices (365x27 or 366x27), which are stored in different files (*.dat). Files with the same name with exception of the year should be concatenated.

For this reason I used the function dir to create a list of files. If file i+1 has the same name as file i, a "1" is written to a vector(vectorX), else a "0" is written.

Finally, I would like to open the files with the same name (function dlmread), concatenate them (function cat) (and finaly store them in another file).

This is the code for the

for j=1:length(vectorX);
if vectorX(j,1)==1
NewMx(:,:)=dlmread(cat(1,files(j,1).name));
end
end

??? Subscripted assignment dimension mismatch.

Please help me. Thank you.
.