Unable to perform assignment because brace indexing is not supported for variables of this type.

1 次查看(过去 30 天)
Hello,
I have these codes and I got an error for example with:
data{iBlob, 1}(4) = dec2bin(iBlob);
dec2bin(4) gives a char '100'.
As far as I know, cell arrays accept different kinds ot types so I don't understand the error here.
Also, how to convert the char '100' into a binary code 100 ?
Thank you for your help.
Best regards
Label = bwlabel(BW);
nbLabels = max(max(Label));
data = cell(nbLabels, 1);
for iBlob = 1:nbLabels
idx = find(Label == iBlob);
% create data
features = regionprops ( (Label==iBlob), 'Centroid' );
data{iBlob, 1}(1) = features.Centroid(2);
data{iBlob, 1}(2) = features.Centroid(1);
data{iBlob, 1}(3) = iBlob;
data{iBlob, 1}(4) = dec2bin(iBlob); % Error here: Unable to perform assignment because brace indexing is not supported for variables of this type.
end

采纳的回答

Walter Roberson
Walter Roberson 2022-5-27
data{iBlob, 1} = features.Centroid(2);
data{iBlob, 2} = features.Centroid(1);
data{iBlob, 3} = iBlob;
data{iBlob, 4} = dec2bin(iBlob) - '0';

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Matrices and Arrays 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by