Hi All,
I am trying to extract to following data with textscan. But I am not able to implement it correctly. Each block consists of 11 data lines and 8 unnecessary lines to exclude.
Data file (testdata.dat) is :
TitleData Header: Time: 100.16064 Sec 10/8/2012 3:32:17 PMData Acquisition: TStation Name: defaultTest File Name: Axial Axial Axial segments mm kN0 -0.19470811 -0.00671407020 -0.19806515 -0.00335703390 -0.19806515 -0.00335703390 -0.19470811 -0.00671407020 -0.16785182 -0.00335703390 -0.16785182 -0.00671407020 -0.13763849 -0.00671407020 -0.12421035 -0.00671407020 -0.10742517 -0.00335703390 -0.11413924 -0.00335703390 -0.14099553 -0.0033570339Data Header: Time: 100.16064 Sec 10/8/2012 3:32:17 PMData Acquisition: TStation Name: defaultTest File Name: Axial Axial Axial segments mm kN0 -0.16785182 -0.00335703390 -0.20813625 -0.00671407020 -0.2316355 -0.00671407020 -0.25513476 -0.00671407020 -0.29206216 -0.00335703390 -0.35584584 -0.00671407020 -0.40620136 -0.00671407020 -0.47334209 -0.00671407020 -0.55055392 -0.00671407020 -0.61098057 -0.00671407020 -0.70162052 -0.010071106
My implementation is
fileID = fopen('testdata.dat');formatSpec = '%d %f %f';clear Ck = 0; N = 11;%Block size
while ~feof(fileID) k = k+1; C(k,1:3) = textscan(fileID,formatSpec,N,'HeaderLines', 8);%'CommentStyle','##',
endfclose(fileID)
Please correct my code. Thanks in advance.
Best Answer