필터 지우기
필터 지우기

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

조회 수: 3 (최근 30일)
Snoopy
Snoopy 2021년 8월 8일
댓글: Snoopy 2021년 8월 8일
Why are the sizes of the two arrays, unique and accumarray, not the same?
size(unique(MAT(:,1)))
size(accumarray(MAT(:,1),MAT(:,2)))

채택된 답변

Matt J
Matt J 2021년 8월 8일
편집: Matt J 2021년 8월 8일
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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Types에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by