Subscripted assignment dimension mismatch for table variable

1 回表示 (過去 30 日間)
Brandon Wong
Brandon Wong 2020 年 4 月 11 日
コメント済み: Brandon Wong 2020 年 4 月 11 日
I'm having troubles preallocating a table. My data looks something similar to this where one of the columns of the table is not just a scalar. What should I put for varTypes?
T_partialdata = table([1;2;3],[4,4;5,5;6,6],[7;8;9])
sz = [10 3];
varTypes = {'double','double','double'};
T = table('Size', sz, 'VariableTypes', varTypes, 'VariableNames', {'A','B','C'})
T(1:3,:) = T_partialdata
  2 件のコメント
Walter Roberson
Walter Roberson 2020 年 4 月 11 日
Your partial data in that code does not have the same variable names as the output table.
Walter Roberson
Walter Roberson 2020 年 4 月 11 日
Variables that are not column scalars are stored as a cell array for each entry. You are trying to store a cell into a double.

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

採用された回答

Mehmed Saad
Mehmed Saad 2020 年 4 月 11 日
I dont know how to define it from size but there's an other way
T_partialdata = table([1;2;3],[4,4;5,5;6,6],[7;8;9])
sz = [10 3];
varTypes = {'double','double','double'};
T = table('Size', sz, 'VariableTypes', varTypes, 'VariableNames', {'A','B','C'});
T.B = zeros(sz(1),2); % defining the size of variable
T(1:3,:) = T_partialdata

その他の回答 (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