find elements which has minmum and maximum probability in an array
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Tommy
2020-4-16
编辑:Tommy
2020-4-16
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Ordinary Differential Equations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!