# Equal method to matlab unique in rows

**URL:** <https://discourse.julialang.org/t/equal-method-to-matlab-unique-in-rows/90240>\
**Category:** General Usage\
**Tags:** question\
**Created:** [November 14, 2022, 2:25pm UTC](https://discourse.julialang.org/t/equal-method-to-matlab-unique-in-rows/90240 "2022-11-14T14:25:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bozaga\_Murat](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bozaga_murat/32/34441_2.png) [@Bozaga\_Murat](https://discourse.julialang.org/u/Bozaga_Murat)\
**Post date:** [November 14, 2022, 2:25pm UTC](https://discourse.julialang.org/t/equal-method-to-matlab-unique-in-rows/90240/1 "2022-11-14T14:25:20Z")

</div>

Hello everyboday, I not found the equal method “unique(x,‘rows’)” in Julia to matlab. Does it know anybody ? Thanks.

---

<div class="post-metadata">

**Author:** ![yha](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yha/32/3502_2.png) [@yha](https://discourse.julialang.org/u/yha)\
**Post date:** [November 14, 2022, 2:40pm UTC](https://discourse.julialang.org/t/equal-method-to-matlab-unique-in-rows/90240/2 "2022-11-14T14:40:49Z")

</div>

I’m not sure if this is exactly what the Matlab function does, but `unique(eachrow(x))` would give you a vector of unique rows.

---

<div class="post-metadata">

**Author:** ![sostock](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sostock/32/5546_2.png) [@sostock](https://discourse.julialang.org/u/sostock)\
**Post date:** [November 14, 2022, 3:37pm UTC](https://discourse.julialang.org/t/equal-method-to-matlab-unique-in-rows/90240/3 "2022-11-14T15:37:05Z")

</div>

The suggested `unique(eachrow(x))` will work, but return a vector of `view`s into the original matrix. To get a matrix (like you would in Matlab), use `unique(x, dims=1)`:

```julia
julia> x = [1 2 3; 4 5 6; 1 2 3]
3×3 Matrix{Int64}:
 1 2 3
 4 5 6
 1 2 3

julia> unique(eachrow(x))
2-element Vector{SubArray{Int64, 1, Matrix{Int64}, Tuple{Int64, Base.Slice{Base.OneTo{Int64}}}, true}}:
 [1, 2, 3]
 [4, 5, 6]

julia> unique(x, dims=1)
2×3 Matrix{Int64}:
 1 2 3
 4 5 6

```
