How to .txt or .rcmp file data with separated by colon?

조회 수: 2 (최근 30일)
Md. Asadujjaman
Md. Asadujjaman 2021년 7월 8일
댓글: dpb 2021년 7월 8일
Hi,
I need to read the following data in Matlab from txt or .rcmp file.
11 0
1 1 0
0 0 0 0 4 1:2 1:3 1:4 1:5
2 1 2 0 2 2:6 2:7
3 1 1 0 1 3:7
5 1 1 0 1 4:7
2 1 2 0 1 5:8
4 2 1 0 1 6:9
2 0 1 0 2 7:9 7:10
6 2 1 0 1 8:10
3 1 0 0 1 9:11
4 1 1 0 1 10:11
0 0 0 0 0
How can I read the above data in Matlab?
  댓글 수: 3
Md. Asadujjaman
Md. Asadujjaman 2021년 7월 8일
Yes. I have tried fileread, and now I can read the data. Problem solved. Thanks.
dpb
dpb 2021년 7월 8일
This is about as badly a formatted file as there is...
>> while ~feof(fid)
l=fgetl(fid);disp(sum(l==9))
end
0
0
8
6
5
5
5
5
6
5
5
5
4
>> fid=fclose(fid);
>>
It's tab delimited except it isn't...this really confuses everything I tried quickly...

댓글을 달려면 로그인하십시오.

채택된 답변

Monika Jaskolka
Monika Jaskolka 2021년 7월 8일
>> fileread('test.txt')
ans =
'11 0
1 1 0
0 0 0 0 4 1:2 1:3 1:4 1:5
2 1 2 0 2 2:6 2:7
3 1 1 0 1 3:7
5 1 1 0 1 4:7
2 1 2 0 1 5:8
4 2 1 0 1 6:9
2 0 1 0 2 7:9 7:10
6 2 1 0 1 8:10
3 1 0 0 1 9:11
4 1 1 0 1 10:11
0 0 0 0 0 '
  댓글 수: 1
dpb
dpb 2021년 7월 8일
>> whos ans
Name Size Bytes Class Attributes
ans 1x215 430 char
>>
leaves with just one long char() string. Have fun parsing the result...

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 String Parsing에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by