Info

この質問は閉じられています。 編集または回答するには再度開いてください。

modify table value = In an assignment A(:) = B, the number of elements in A and B must be the same.

1 回表示 (過去 30 日間)
RuiQi
RuiQi 2016 年 12 月 10 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
I get this error when trying to pad the values of one column of my table with zeros.
In an assignment A(:) = B, the number of elements in A and B must be the same.
grnd_truth_table = readtable('ground_truth.txt','Delimiter',' ','ReadVariableNames',false);
%
for i=1:size(grnd_truth_table,1)
buf = sprintf('%06i',grnd_truth_table.Var1(i));
grnd_truth_table.Var1(i) = buf;
end
grnd_truth_table.Var1 are all integers.

回答 (1 件)

Image Analyst
Image Analyst 2016 年 12 月 10 日
If Var1 is a string variable in your table, then because you're assigning a string "buf" to it, maybe you need
grnd_truth_table(1, "Var1") = buf; % Maybe {} instead of ()???
You forgot to attach 'ground_truth.txt' so I can't really try anything for you. Good luck though.
Can you even do this:
grnd_truth_table.Var1(i)
when you try sprintf() or does that bomb?

この質問は閉じられています。

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by