which(data==max(data),arr.ind=TRUE)
gives you the indices of the largest element.
which(data==data[order(data)[2]],arr.ind=TRUE)
the indices of the second largest.
Best
Jannis
On 04/14/2011 10:23 PM, Nicolas Gutierrez wrote:
hi All,
I have a matrix Ufi (x by y)
1 2 3 4 5
1 0 0 0 0
hi All,
I have a matrix Ufi (x by y)
1 2 3 4 5
1 0 0 0 0 3
2 0 0 0 9 0
3 0 2 0 0 3
4 0 0 1 0 0
5 0 1 0 0 0
And I need the x and y "coordinates" of those cells with maximum values:
First:
x=4; y=2 (Value=9)
Second:
x=5; y=3 (value=3)
Any help?
THANKS!
Nic
_
Hi All,
I have the following matrix Ufi (x by y):
Ufin
1 2 3 4 5 6 7 8 9 10
1 0 0 0 0 0 0 0 0 0 0
2 0 0 0 0 0 0 0 0 0 0
3 0 0 0 0 0 0 0 0 0 0
4 0 0 0 6 0 0 0 0 0 0
5 0 0 0 0 0 0 0 0 0 0
6 0 0 0 0 0 0 9 0 0 0
7 0 2 0 0 0 0 0 0 0 0
8 0 0 0 0 0 0 0 0 0 0
3 matches
Mail list logo