How to load a specially formatted data file into matlab?
1 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
采纳的回答
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Low-Level File I/O 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!