Unable to perform assignment because brace indexing is not supported for variables of this type.
1 view (last 30 days)
Show older comments
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
Accepted Answer
Walter Roberson
on 27 May 2022
data{iBlob, 1} = features.Centroid(2);
data{iBlob, 2} = features.Centroid(1);
data{iBlob, 3} = iBlob;
data{iBlob, 4} = dec2bin(iBlob) - '0';
0 Comments
More Answers (0)
See Also
Categories
Find more on Data Type Conversion in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!