How to read iiregular mixed numeric and string data
조회 수: 20 (최근 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에서 Text Files에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!