Textscan to choose the specific text

Hello, I have the following .csv file and I want to read only -0.192 and -0.168 from the third and the fourth line and ignore rest:
"Record Length",1000000,"Points"
"Trigger Time",0,s
,,,-9.99988E-06,-0.192
,,,-9.99986E-06,-0.168
I am using the following code to remove the header in the first two lines:
fid = fopen('wave00000001.csv','r');
datacell = textscan(fid, '%f64', 'HeaderLines', 2);
prbs = cell2mat(datacell);
fclose(fid);
How can I remove the ,,,-9.99E-06 values from the 3rd and the 4th line.
Thanks and Cheers, Ahmad

 採用された回答

per isakson
per isakson 2014 年 10 月 13 日
編集済み: per isakson 2014 年 10 月 13 日

0 投票

Replace
'%f64'
by
'%*f%*f%*f%f%f'
"64" is by default

3 件のコメント

per isakson
per isakson 2014 年 10 月 14 日
編集済み: per isakson 2014 年 10 月 14 日
Thanks Per Isakson. It works :) However I have to change the %*f to %*c.
I have quite big data file to read. It is 1000000x1 matrix. However, I can only get the first 23,000 values (e.g. 23000x1). How can a large data file be read using textscan.
Thanks
(move from separate answer to comment by per isakson. @Almad, please delete the empty answer. I'm not allowed.)
per isakson
per isakson 2014 年 10 月 14 日
  • "I can only get the first 23,000 values" &nbsp And there are no error or warning(?). I'm pretty sure there is something in line 23000/2+1, which does not match the format specifier.
  • " change the %*f to %*c" &nbsp That's strange, I actually tested and work for me with %*f. Nevermind.
Ahmad Mustafa
Ahmad Mustafa 2014 年 10 月 22 日
Great. It works. Many thanks for your help :)
Cheers, Ahmad

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeCharacters and Strings についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by