Change Size of Array in table

28 ビュー (過去 30 日間)
Arne T
Arne T 2020 年 8 月 24 日
回答済み: Nagasai Bharat 2020 年 8 月 27 日
Hey All,
I am new to Matlab and have a table with a subtable in some cells. My main Table (MM) has dynamic size and the subtable, which is in the 9th cell of each row has to have a subtable with the width of the hight of the Maintable. I have trouble if i add a row to add a column to the subtable. My Idea is:
for i = 1:size(MM,1)
MM{i,9} = table([MM{1,9}{1,1} 1]);
end
Following error message comes up: "Subscripted assignment dimension mismatch for table variable 'Var1'."
I also tried the following:
for i = 1:size(MM,1)
MM{i,9}{1,1} = [MM{1,9}{1,1} 1];
end
Following error message comes up: "The value on the right-hand side of the assignment has the wrong width. The assignment requires a value whose width is 3."
It seems like I cant change the size of the subtable but dont get why. Please help me.
Thank you!
Arne
  2 件のコメント
dpb
dpb 2020 年 8 月 24 日
Attach a .mat file with a small example of the table structure and illustrate what you want the result to be...
Arne T
Arne T 2020 年 8 月 25 日
I added the table.mat file. The Variable MM is the table. For adding a row I have following code
function addSolution(pos, solution)
%%fügt der Tabelle tabelle eine technische Lösung hinzu
tabelle = getMM(pos);
rows = height(tabelle);
columns = width(tabelle);
T = table();
for i = 1:8
T = [T table(0)];
T.Properties.VariableNames{i} = tabelle.Properties.VariableNames{i};
end
T = [T {table(ones(1,rows))}];
T.Properties.VariableNames{9} = tabelle.Properties.VariableNames{9};
for i = 10:columns
T = [T table(addCell)];
T.Properties.VariableNames{i} = tabelle.Properties.VariableNames{i};
end
T.Properties.RowNames = {solution};
if rows == 0
tabelle = T;
else
tabelle = [tabelle;T];
end
setMM(pos,tabelle);
for i = 1 : rows+1
modules = [table2array(getMM([pos;i,9])) 1];
setMM([pos;i,9],{modules});
end
The pos variable is in first step emtpy [].
The last four Rows in this code should add a column to the Matrix in the 9th cell. This still dont work.

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

採用された回答

Nagasai Bharat
Nagasai Bharat 2020 年 8 月 27 日
Hi Arne,
My understanding is that you are looking into changing the dimensions of your sub-tables. In MATLAB you would be able to add nested/sub tables inside your main table of desirable width/variables but the number of rows of each sub-table should be equal to the number of rows of the main table.
For reference please do look into this answer.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeNucleotide Sequence Analysis についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by