# Find index of maximum value of array

**URL:** https://discourse.julialang.org/t/find-index-of-maximum-value-of-array/51525
**Category:** New to Julia
**Tags:** question
**Created:** [December 9, 2020, 1:37pm UTC](https://discourse.julialang.org/t/find-index-of-maximum-value-of-array/51525 "2020-12-09T13:37:34Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Luigi\_Marongiu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/luigi_marongiu/32/7909_2.png) [@Luigi\_Marongiu](https://discourse.julialang.org/u/Luigi_Marongiu)
#### Post date: [December 9, 2020, 1:37pm UTC](https://discourse.julialang.org/t/find-index-of-maximum-value-of-array/51525/1 "2020-12-09T13:37:34Z")

</div>

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

```julia

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

---

<div class="post-metadata">

### Author: ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)
#### Post date: [December 9, 2020, 1:47pm UTC](https://discourse.julialang.org/t/find-index-of-maximum-value-of-array/51525/2 "2020-12-09T13:47:37Z")

</div>

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