Borrar filtros
Borrar filtros

Size of the unique elements and size of the output of accumarray

2 visualizaciones (últimos 30 días)
Why are the sizes of the two arrays, unique and accumarray, not the same?
size(unique(MAT(:,1)))
size(accumarray(MAT(:,1),MAT(:,2)))

Respuesta aceptada

Matt J
Matt J el 8 de Ag. de 2021
Editada: Matt J el 8 de Ag. de 2021
They will only be the same size if unique(MAT(:,1)) consists of consecutive integers starting from 1. Otherwise, accumarray must leave certain spots blank. A simpler example:
accumarray([2;4],1)
ans = 4×1
0 1 0 1

Más respuestas (0)

Categorías

Más información sobre Tables en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by