How can i name the column on a table ?

조회 수: 13 (최근 30일)
Giorgia Fusaroli
Giorgia Fusaroli 2021년 5월 26일
댓글: Stephen23 2021년 5월 26일
HI everyone,
I have a matrix (82600x156 double) from a c3d file. I need to built a table and associate at each column a specific name. I already built a vector 'label' (1x156 cells). Using the command:
T = table (matrix, 'VariableNames', label)
the error is "The VariableNames property must contain one name for each variable in the table.".
I need this to save the table in .csv format.
If someone has suggestion about how my problem can be solved or another way to say labels and matrix on a cvs file it will be realy great !

채택된 답변

Stephen23
Stephen23 2021년 5월 26일
편집: Stephen23 2021년 5월 26일
You created a table with one variable and one row, and that variable contains a large numeric matrix. This is not useful for you. If you want a table where each column is converted into a table variable/column then use array2table:
T = array2table(matrix, 'VariableNames', label)
  댓글 수: 4
Giorgia Fusaroli
Giorgia Fusaroli 2021년 5월 26일
The input is a c3d matrix (82600x156 double). The output that i would is a csv (so a file where the elements of the row are devided by a ','). I need to label the column of the matrix and i already did a variable named "label" (1x156 cells). The format of the label is similar to "signal_rx_1:1".
The problem is that the alreayd build functions for csv have problems with mixed input (cells and double) and so first i need to build a table and then i need to save the table as a .csv file, but this is not the problem now because i have problem in the construction of the table.
with array2table MatLab gives me a message of error due to the invalid variable name (which, like i said is in format of a cell).
if you need another information to help me, just ask :)
Stephen23
Stephen23 2021년 5월 26일
MATLAB R2019b and later will accept table variable names containing any characters.
If you are using an earlier version then the table variable names will need to be valid MATLAB variable names: https://www.mathworks.com/help/matlab/matlab_prog/variable-names.html
For example, this means you will need to remove the colon character.

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

추가 답변 (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