To find the location of maximum number
1 view (last 30 days)
Show older comments
fyza affandi
on 28 Dec 2018
Commented: Star Strider
on 28 Dec 2018
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 Comments
Accepted Answer
Star Strider
on 28 Dec 2018
a= [1 2 5 7 7 5 3];
allmaxidx = find(a == max(a(:)))
producing:
allmaxidx =
4 5
2 Comments
More Answers (0)
See Also
Categories
Find more on Resizing and Reshaping Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!