find elements which has minmum and maximum probability in an array
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
PANTHAGADA ANIL KUMAR
le 16 Avr 2020
Modifié(e) : Tommy
le 16 Avr 2020
i need to get the elements which has minimum and maximum probablities from A = [ 1,2,3,4,5,6,7] & P = [ 0.01,0.01,0.25.0.2,0.25,0.09,0.19] ................
i need output as for min prob either (1 or 2) and for max prob either (3 or 5)
0 commentaires
Réponse acceptée
Tommy
le 16 Avr 2020
Modifié(e) : Tommy
le 16 Avr 2020
A = [ 1,2,3,4,5,6,7];
P = [ 0.01,0.01,0.25,0.2,0.25,0.09,0.19];
minprob = A(P==min(P))
maxprob = A(P==max(P))
minprob =
1 2
maxprob =
3 5
(edit) If you want to pick one number among the outputs at random:
A = [ 1,2,3,4,5,6,7];
P = [ 0.01,0.01,0.25,0.2,0.25,0.09,0.19];
minprob = A(P==min(P));
minprob = minprob(randi(1:numel(minprob)))
maxprob = A(P==max(P));
maxprob = maxprob(randi(1:numel(maxprob)))
minprob =
1
maxprob =
5
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Ordinary Differential Equations dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!