d=[];
fmt=repmat('%f',1,14);
fid=fopen('filename');
for i=1:10
d=[d;cell2mat(textscan(fid,fmt,12,'headerlines',2, ...
'collectoutput',1 ...
'delimiter',','))];
fgetl(fid)
end
fid=fclose(fid);
The above returns the data in one array; if you instead want each simulation separately, instead of the concatenation above use a cell array to store each read section--
ERRATUM
fmt=[repmat('%f',1,14) '\n'];
fid=fopen('filename');
for i=1:10
d(i)=textscan(fid,fmt,12,'headerlines',2, ...
'collectoutput',1 ...
'delimiter',',')];
end
fid=fclose(fid);
NB: The \n (newline) in the format string solves the position in the file it seems. I guess it's one of those cases where it's probably technically wrong without it but the scanning routines skip over it transparently in the vectorized portion but not when the scan is started over. Again, "why" is indecipherable as far as I can tell, it "just is".
Best Answer