Read a text file with varying number of colums
이전 댓글 표시
I am trying to read a text file with varying number of columns, such as this:
#5:v3.0_ST:1:2631.1301,N:140.0:081.000:12.5;
#5:v3.0_ST:1:2631.1301,N:111.4:100.000:12.5:18.7:32.3;
#5:v3.0_ST:1:2631.1299,N:111.5:101.000:12.5:18.7:32.3;
#5:v3.0_ST:1:2631.1315,N:136.4:082.000:12.3;
#5:v3.0_ST:1:2631.1334,N:132.8:083.000:12.4;
The data is delimited by " : " (colon). I understand, there is some way of doing this using textscan, but I do not know how to do it for varying columns. Can someone give me a hint?
Thanks
댓글 수: 4
dpb
2015년 1월 11일
HINT:
doc fgetl
Your file has no clues in it for how many items there are per line other than counting delimiters on a line-by-line basis, unfortunately. Hence, that's the only way...
per isakson
2015년 1월 12일
What's the role of "," ?
Pankaj
2015년 1월 12일
Pankaj
2015년 1월 12일
채택된 답변
추가 답변 (1개)
Aditya Dua
2015년 1월 11일
0 개 추천
I tried this on the file segment you posted and it worked:
inp = importdata('file.txt'); where inp(k) contains the k^th line of the text file.
I'm using MATLAB R2014b
Aditya
카테고리
도움말 센터 및 File Exchange에서 Graphics Object Properties에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!