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

 Akzeptierte Antwort

per isakson
per isakson am 13 Okt. 2014
Bearbeitet: per isakson am 13 Okt. 2014

0 Stimmen

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

3 Kommentare

per isakson
per isakson am 14 Okt. 2014
Bearbeitet: per isakson am 14 Okt. 2014
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 am 14 Okt. 2014
  • "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 am 22 Okt. 2014
Great. It works. Many thanks for your help :)
Cheers, Ahmad

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Characters and Strings finden Sie in Hilfe-Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by