Find index of maximum value of array

I have an array and I woul dlike to find the index of the maximum value. I tried with:


julia> X = [0,0,0,0,0,0,0,0,5,0,0,0,0,1]
14-element Array{Int64,1}:
 0
 0
 0
 0
 0
 0
 0
 0
 5
 0
 0
 0
 0
 1

julia> find(x == maximum(x), X)
ERROR: UndefVarError: x not defined
Stacktrace:
 [1] top-level scope at none:0

What would be the correct syntax? Thank you

You could use findfirst(x -> x == maximum(X), X) or findfirst(==(maximum(X)), X), but the easiest thing to do is argmax(X).

10 Likes