Importing table from text file and matching header to column
이전 댓글 표시
Hi everyone,
Here is an example of my data:
# r CAC-CAC CAC-OAC
0.2700000E+01 0.0000000E+00 0.0000000E+00 0.3860216E-03 0.2814651E-01
0.2730000E+01 0.0000000E+00 0.0000000E+00 0.3775852E-03 0.2753156E-01
0.2760000E+01 0.0000000E+00 0.0000000E+00 0.5541359E-02 0.1041859E+00
0.2790000E+01 0.0000000E+00 0.0000000E+00 0.7230470E-02 0.1176749E+00
0.2820000E+01 0.0000000E+00 0.0000000E+00 0.1096994E-01 0.1432550E+00
0.2850000E+01 0.0000000E+00 0.0000000E+00 0.1870899E-01 0.1847078E+00
I would like to import my data into a table, with the text in the first row used as a variable for each column that it lines up with. The unwanted "#" character and the inconsistent spacing at the start of the first row means that readtable(example_data.txt); does not does not produce the correct headers for the table and instead leads to Var1, Var2,..., ect.
For example, in Excel the import data option slices up the data and the headers end up in the correct location in the imported table:

Note that some of the columns do not have headers and I do not require this data in my imported table.
I am very new to MATLAB, so any help is very appreciated!
Cheers!
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Text Files에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
