필터 지우기
필터 지우기

How to load a specially formatted data file into matlab?

조회 수: 3 (최근 30일)
liangjian
liangjian 2011년 9월 7일
I need to load a data file, test.dat, into Matlab. The contents of data file are like
*a682 1233~0.2
*a2345 233~0.8 345~0.2 4567~0.3
*a3457 345~0.9 34557~1.2 34578~0.2 9809~0.1 2345~2.9 23452~0.9 334557~1.2 234578~0.2 19809~0.1 23452~2.9 3452~0.9 4557~1.2 3578~0.2 92809~0.1 12345~2.9 232452~0.9 33557~1.6 23478~0.6 198099~2.1 234532~2.9
How to read this type of file into matlab, and use the terms, such as *2345 to identify a row, which links to corresponding terms, including 233~0.8 345~0.2 4567~0.3
Thanks.

채택된 답변

Walter Roberson
Walter Roberson 2011년 9월 7일
Please expand on this. For example, the first line:
*a682 1233~0.2
How would you like that to be stored in MATLAB?
Is the character in-between always the tilde character? Do the numbers always occur in pairs with the ~ between them? Do negative numbers ever occur? Do you want the pairs stored as a string or as a vector of two numeric values with the ~ left out? Is there ever a decimal point in the number before the ~ or is always an integer?
Should
*a2345 233~0.8 345~0.2
become {'*a2345' [233 0.8] [345 0.2]} or should it become {'*a2345' [233] [0.8] [345] [0.2]} or should it become {'*a2345' [233 0.8 345 0.2]} or something else?

추가 답변 (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