skip the headers in a text file and extract the data ?

98 次查看(过去 30 天)
I would like to extract the data only from a text file. the text file has a header which contains some numerical values as shown below?
Matrix detected
Double precision storage used.
Matrix size is 5 x 5
Matrix elements a(m,n)
m: matrix row
n: matrix column
m n value
1 1 -4.741986825761376E+00
2 1 -4.630424392475458E+00
3 1 -4.307409743346405E+00
4 1 -3.804889997051831E+00
5 1 -3.171836516325863E+00
1 2 -4.630424380271435E+00
2 2 -4.741959894978010E+00
3 2 -4.630411248725576E+00
4 2 -4.307409755549543E+00
5 2 -3.804868350860215E+00
1 3 -4.307409755549557E+00
2 3 -4.630411248725565E+00
3 3 -4.741959894978017E+00
4 3 -4.630424380271435E+00
5 3 -4.307397514355404E+00
1 4 -3.804889997051820E+00
2 4 -4.307409743346408E+00
3 4 -4.630424392476307E+00
4 4 -4.741986825762240E+00
5 4 -4.630424392476300E+00
1 5 -3.171836516321907E+00
2 5 -3.804868350853141E+00
3 5 -4.307397514355404E+00
4 5 -4.630424380271435E+00
5 5 -4.741959894978017E+00

采纳的回答

KSSV
KSSV 2016-11-25
编辑:KSSV 2016-11-25
doc textscan
fid = fopen('your text file') ;
data = textscan(fid,'%f %f %f','HeaderLines',7) ;
data = cell2mat(data)
fclose(fid);

更多回答(0 个)

类别

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