How to find a minimum value of a matrix according to another matrix?

2 ビュー (過去 30 日間)
anil hamzacebi
anil hamzacebi 2020 年 12 月 29 日
コメント済み: anil hamzacebi 2020 年 12 月 29 日
Hello everyone!!!
I have two 1x10 matrixes named A and B.
A=[1 1 2 3 3 2 4 5 4 5];
B=[0 3 10 6 15 22 23 28 21 25];
I need to find the each minimum values of B while A has different values. For example;
while A is 1, minimum of B is 0
while A is 2, minimum of B is 10
while A is 3, minimum of B is 6
...
I hope you can help me, thank you!!!

採用された回答

Bruno Luong
Bruno Luong 2020 年 12 月 29 日
編集済み: Bruno Luong 2020 年 12 月 29 日
A=[1 1 2 3 3 2 4 5 4 5];
B=[0 3 10 6 15 22 23 28 21 25];
[AU,~,AA]=unique(A(:));
MB=accumarray(AA,B(:),[],@min);
[AU,MB]
  1 件のコメント
anil hamzacebi
anil hamzacebi 2020 年 12 月 29 日
This works exactly the way I need!! Thank you...

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeProgramming についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by