How to read iiregular mixed numeric and string data
12 ビュー (過去 30 日間)
古いコメントを表示
Hi, I have a complex text file as below(it is same with attached file). It is mixed with string and numeric columns, also one of them is irregular data with mixed string and numeric as the "mdata" column. I want to read all the data as a matrix variable from this formatted file. How can I do this?
num1 num2 str1 num3 str2 mdata num4 str3
1 2 AB 3 4CD005 6.1234 11 EF
1 2 GH 0 4CD005 IJ -11 EF
1 3 KL 2 4CD005 -7.3456 11 MN
2 1 OP 3 4CD005 2.0001 11 QR
2 3 ST 1 4CD005 -10.6789 -11 UV
回答 (1 件)
Jayaram Theegala
2017 年 4 月 5 日
As KSSV has suggested, you can use the "readtable" command as shown below to read the data from your file as a table:
readtable('complex_data.txt')
For more information about "readtable", click on the following URL:
2 件のコメント
Jayaram Theegala
2017 年 4 月 6 日
You can access the individual elements in the table, by using the column names. For instance, if column names are "num1" and "num2", you can add the second row, first two column elements as follows:
t.num1(2) + t.num2(2)
For more information about using "Tables" in MATLAB, click on the following URL:
参考
カテゴリ
Help Center および File Exchange で Data Import and Export についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!