Can I use 'table' as a variable type in a table
34 ビュー (過去 30 日間)
古いコメントを表示
Help for 'table' says that I can use 'table' as a variable type in a table. I receive the error msg;
"The value on the right-hand side of the assignment has the wrong width. The assignment requires a value whose width is 0"
when trying to run the following code.
InnerTable = table('Size',[1 2],'VariableTypes',{'double', 'double'});
InnerTable{2,1} = 14.34;
InnerTable{3,2} = 45;
Table = table('Size',[1 3],'VariableTypes',{'table', 'double', 'struct'});
Table{1,1} = InnerTable;
Can a table be assigned to a location within a table? How?
4 件のコメント
Stephen23
約10時間 前
編集済み: Stephen23
約8時間 前
"I was expecting (hoping) that a table of any size could be assigned to a single cell in another table. Clearly not. Time to approach my problem another way."
Tables do not have "cells". Every variable/column of a table is simply an array, which means there is absolutely nothing stopping you from using a cell array as one of those columns, if you need. Then you can allocate a nested table of any size to that variable (i.e. cell array) of the parent table. But do not confuse tables themselves with "cells" (which they definitely do not have).
採用された回答
Voss
約19時間 前
InnerTable = table('Size',[1 2],'VariableTypes',{'double', 'double'});
InnerTable{2,1} = 14.34;
InnerTable{3,2} = 45
Table = table('Size',[height(InnerTable) 3],'VariableTypes',{'table', 'double', 'struct'})
% 4 alternatives:
Table.(1) = InnerTable;
Table.Var1 = InnerTable;
Table{:,1} = InnerTable;
Table{:,'Var1'} = InnerTable;
Table
2 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Structures についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!