VariableNames for table that begins with number

7 ビュー (過去 30 日間)
NA
NA 2021 年 6 月 2 日
コメント済み: NA 2021 年 6 月 2 日
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 件のコメント
KSSV
KSSV 2021 年 6 月 2 日
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 2021 年 6 月 2 日
Thank you

サインインしてコメントする。

採用された回答

Steven Lord
Steven Lord 2021 年 6 月 2 日
The ability to use table variable names that are not valid MATLAB variable names was introduced in release R2019b.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeTables についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by