VariableNames for table that begins with number

7 Ansichten (letzte 30 Tage)
NA
NA am 2 Jun. 2021
Kommentiert: NA am 2 Jun. 2021
I have matrix like this
A =[4 1 0 0;5 0 1 1;6 1 0 1; 7 0 1 0];
I want to make a table with this variable name
Var_name = {[1,3,4],[4,7,8],[1,2]};
The result should be
index [1,3,4] [4,7,8] [1,2]
4 1 0 0
5 0 1 1
6 1 0 1
7 0 1 0
I used this code
T = array2table(A,'VariableNames',{'index' '{1,3,4}' '{4,7,8}' '{1,2}'});
But it does not work.
  2 Kommentare
KSSV
KSSV am 2 Jun. 2021
A =[4 1 0 0;5 0 1 1;6 1 0 1; 7 0 1 0];
T = array2table(A,'VariableNames',{'index' '{1,3,4}' '{4,7,8}' '{1,2}'});
T
T = 4×4 table
index {1,3,4} {4,7,8} {1,2} _____ _______ _______ _____ 4 1 0 0 5 0 1 1 6 1 0 1 7 0 1 0
It is working...what version you are using?
NA
NA am 2 Jun. 2021
Thank you

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Steven Lord
Steven Lord am 2 Jun. 2021
The ability to use table variable names that are not valid MATLAB variable names was introduced in release R2019b.

Weitere Antworten (0)

Kategorien

Mehr zu Tables finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by