unique and min by index
5 ビュー (過去 30 日間)
古いコメントを表示
Hi, if I have A=[1 1 1 2 2 3 3 3] as unique values and B=[ 5 6 7 4 1 2 2 3]. I want to find the min and difference as [5 5 5 1 1 2 2 2] and [0 1 2 3 0 0 0 1]. How may i do that? thanks.
0 件のコメント
回答 (1 件)
Walter Roberson
2015 年 12 月 16 日
group_min = accumarray(A(:), B(:), [], @min);
result1 = group_min(A);
result2 = B - result1;
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!