How to find a minimum value of a matrix according to another matrix?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
anil hamzacebi
am 29 Dez. 2020
Kommentiert: anil hamzacebi
am 29 Dez. 2020
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!!!
0 Kommentare
Akzeptierte Antwort
Bruno Luong
am 29 Dez. 2020
Bearbeitet: Bruno Luong
am 29 Dez. 2020
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]
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Resizing and Reshaping Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!