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

1 view (last 30 days)
Snoopy on 8 Aug 2021
Commented: Snoopy on 8 Aug 2021
Why are the sizes of the two arrays, unique and accumarray, not the same?

Accepted Answer

Matt J
Matt J on 8 Aug 2021
Edited: Matt J on 8 Aug 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:
ans = 4×1
0 1 0 1

More Answers (0)


Community Treasure Hunt

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

Start Hunting!