Unable to perform assignment because brace indexing is not supported for variables of this type.
2 ビュー (過去 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
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 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Matrices and Arrays についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!