Unable to perform assignment because brace indexing is not supported for variables of this type.
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Maia2022
el 27 de Mayo de 2022
Comentada: Maia2022
el 27 de Mayo de 2022
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
Respuesta aceptada
Walter Roberson
el 27 de Mayo de 2022
data{iBlob, 1} = features.Centroid(2);
data{iBlob, 2} = features.Centroid(1);
data{iBlob, 3} = iBlob;
data{iBlob, 4} = dec2bin(iBlob) - '0';
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Matrices and Arrays en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!