Adding a variable to a table

조회 수: 3 (최근 30일)
Newbie
Newbie 2020년 11월 23일
댓글: Newbie 2020년 11월 30일
Suppose I have a table with row names but no variable names. I want to make the first row in my table (attached) to be recognized as the variables in my table and be able to have variables as my x axe in a plot when ploting the rows as a time series.

채택된 답변

Nagasai Bharat
Nagasai Bharat 2020년 11월 27일
Hi,
From my understanding you are trying make your first row as the variables of your table Tx. The following script would help you achieve it.
load Tx
VarNames = string(cell2mat(table2cell(Tx(1,:))));
Tx(1,:) = [];
Tx.Properties.VariableNames = VarNames;
  댓글 수: 1
Newbie
Newbie 2020년 11월 30일
Hi Nagasai,
I ran the script and got the following message:
'300' is not a valid table variable name. See the documentation for isvarname or matlab.lang.makeValidName for more information.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by