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

1 Ansicht (letzte 30 Tage)
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

Akzeptierte Antwort

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

Weitere Antworten (0)

Kategorien

Mehr zu Matrices and Arrays finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by