Add names to table variables from a large cell
1 回表示 (過去 30 日間)
古いコメントを表示
I have a 1x72 cell with name like 'Var_name'
Var_name = {[1,3,4],[4,7,8],[1,2],...,[4,6,7],[5,6,8]}; ---> 1x72 cell
and have a matrix A
A = [4 1 0 0...; 5 0 1 1...; 6 1 0 1...; 7 0 1 0...; ...]; ---> 10x72 double
I would like to have a Table that has variable names based on the above cell with Var_name, like this...
index [1,3,4] [4,7,8] [1,2] [4,6,7] [5,6,8]
4 1 0 0 ...
5 0 1 1 ...
6 1 0 1 ...
7 0 1 0 ...
. . . .
I used this code, but it does not work
Var_name_string = cellfun(@(a)string(a),Var_name,'uni',0);
T = array2table(A.','variablenames',{'index' Var_name_string});
instead of ---> T = array2table(A,'VariableNames',{'index' '{1,3,4}' '{4,7,8}' '{1,2}' ....'{4,6,7}' '[5,6,8]'});
0 件のコメント
採用された回答
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Tables についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!