フィルターのクリア

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

2 ビュー (過去 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 Center および File ExchangeTables についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by