To find the location of maximum number
1 次查看(过去 30 天)
显示 更早的评论
I have a array
a= [1 2 5 7 7 5 3]
I want to get the location of the maximum number(for this example =7)
I use this code
[x,y]=max(t1)
x=
7
y=
4
the code only shows one location. What can I change in the code two get 2 location which is 4 and 5 instead of 4?
y =
4
5
0 个评论
采纳的回答
Star Strider
2018-12-28
a= [1 2 5 7 7 5 3];
allmaxidx = find(a == max(a(:)))
producing:
allmaxidx =
4 5
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Resizing and Reshaping Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!