# Access row of matrix based on when value is equal to something specific

**URL:** <https://discourse.julialang.org/t/access-row-of-matrix-based-on-when-value-is-equal-to-something-specific/36149>\
**Category:** New to Julia\
**Tags:** question\
**Created:** [March 18, 2020, 4:11pm UTC](https://discourse.julialang.org/t/access-row-of-matrix-based-on-when-value-is-equal-to-something-specific/36149 "2020-03-18T16:11:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![samantp](https://avatars.discourse-cdn.com/v4/letter/s/f475e1/32.png) [@samantp](https://discourse.julialang.org/u/samantp)\
**Post date:** [March 18, 2020, 4:11pm UTC](https://discourse.julialang.org/t/access-row-of-matrix-based-on-when-value-is-equal-to-something-specific/36149/1 "2020-03-18T16:11:03Z")

</div>

Hi, Sorry that this is such a simple question but I have not been able to figure this out.

I have a 1787x2 matrix stored as an array (called `dvh_bs`, and I want to access the row in which the second column is equal to 0.5. How would I do this without constructing a for loop?

Thanks

---

<div class="post-metadata">

**Author:** ![mbaz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbaz/32/17295_2.png) [@mbaz](https://discourse.julialang.org/u/mbaz)\
**Post date:** [March 18, 2020, 4:17pm UTC](https://discourse.julialang.org/t/access-row-of-matrix-based-on-when-value-is-equal-to-something-specific/36149/2 "2020-03-18T16:17:59Z")

</div>

```julia
a = rand(10,2)

b = a[:,2] .> 0.5

a[b,:]
5×2 Array{Float64,2}:
 0.610937 0.578347
 0.991965 0.681461
 0.553017 0.820753
 0.47222 0.997207
 0.0896303 0.740422

```

Just use `.==` or maybe `isapprox` instead of `.>`
