How to also read the first row correctly with 'readtable'

조회 수: 51 (최근 30일)
Fabian Murre
Fabian Murre 2018년 4월 9일
답변: Guillaume 2018년 4월 9일
Hello,
I am trying to import an Excel table to Matlab. I used the following command:
T = readtable('Stoomtabellen Excel.xlsx','ReadRownames',true);
In which 'Stoomtabellen Excel.xlsx' is the Excel file. The first row of the table is the variable 'p' (for pressure). You can see this in the attached image. But when it's converted (see other image), the first row shows up correctly, only the variable 'p' is missing. I used 'Readrownames', true, so why doesn't it read the first row correctly 'p'. My question is: how can I make the row 'p' separate from the first row (the 1,2,3, etc. row). I also tried using 'xlsread' and put the 'p' row in a separate row but it didn't include the row names. Thanks in advance.

채택된 답변

Guillaume
Guillaume 2018년 4월 9일
You seem to be confusing rows and columns. 'ReadRowNames', true means use the values in the 1st column to name the rows. In your case, it should be:
T = readtable('Stoomtabellen Excel.xlsx','ReadVariableNames',true);
or simply
T = readtable('Stoomtabellen Excel.xlsx');
since 'ReadVariableNames' is true by default.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by