MATLAB: How to load ASCII dat file to MATLAB

loadMATLABtextscan

After reading some articles in the forum, I used textscan to load my .dat file to MATLAB. Unfortunately, MATLAB only read the first line of my .dat file.
  • load does not work, most likely because 7th column is double followed by "….."
fid=fopen('newtext.dat');
C=textscan(fid,'%d %d %d %d %d %d %d');
this led to
C=
[775841] [644] [552] [1185] [617] [534] [1153]
Any hints or answers to this problem would be appreciated!
Here's a sample of my .dat file:
775841 643.5 551.6 1185.0 617.3 533.6 1153.0 .....
775843 643.6 552.3 1185.0 621.0 531.8 1153.0 .....
775845 643.6 552.9 1185.0 624.7 530.1 1152.0 .....
775847 643.4 553.4 1185.0 625.6 529.7 1153.0 .....
775849 643.1 553.4 1186.0 622.8 530.7 1154.0 .....
775851 642.8 553.5 1187.0 620.0 531.7 1154.0 .....
775853 642.9 554.0 1187.0 616.6 534.4 1154.0 .....
775855 643.1 554.8 1186.0 613.3 537.3 1154.0 .....
775857 643.5 555.5 1185.0 614.4 538.2 1154.0 .....
775859 643.7 555.5 1184.0 618.7 536.3 1155.0 .....

Best Answer

fid=fopen('newtext.dat');
fmt=[repmat('%f',1,7) '.....']; % include the junk as pattern matching
C=cell2mat(textscan(fid,fmt,'collectoutput',true));
should give a single array of all the values.