Reading Specific Lines and Coulmns

2 次查看(过去 30 天)
Hi all,
I'm trying to read specific lines from a file and I want to translate them into array. My template is like that:
Curveplot
Time
Z-force
Contact Id
Sl 1 #pts=151
* Minval= -3.710350e+003 at time= 0.002740
* Maxval= 2.669760e+003 at time= 0.001000
0.000000e+000 0.000000e+000
1.993210e-005 5.299370e+002
3.999280e-005 1.217220e+003
5.992490e-005 1.437750e+003
7.998550e-005 1.571400e+003
9.991760e-005 1.662600e+003
1.199780e-004 1.707430e+003
1.399100e-004 1.769070e+003
... ...
2.959890e-003 -3.544220e+003
2.979920e-003 -3.536640e+003
2.999960e-003 -3.529960e+003
endcurve
I need to take the second coulmn values between the line 8 and the last.
I'm waiting for your suggestions and answers.

回答(1 个)

Michael Haderlein
Michael Haderlein 2014-8-19
Dear Köksal,
you can simply use textscan:
fid=fopen(filename);
data=textscan(fid,'%*f%f','delimiter','\t','MultipleDelimsAsOne',true,'headerlines',7)
fclose(fid);

类别

Help CenterFile Exchange 中查找有关 Data Import and Export 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by