# Unique (indices) method similar to MATLAB

**URL:** <https://discourse.julialang.org/t/unique-indices-method-similar-to-matlab/34446>\
**Category:** General Usage\
**Tags:** question\
**Created:** [February 11, 2020, 12:35am UTC](https://discourse.julialang.org/t/unique-indices-method-similar-to-matlab/34446 "2020-02-11T00:35:27Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![lungben](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lungben/32/12314_2.png) [@lungben](https://discourse.julialang.org/u/lungben)\
**Post date:** [February 11, 2020, 7:04am UTC](https://discourse.julialang.org/t/unique-indices-method-similar-to-matlab/34446/3 "2020-02-11T07:04:21Z")

</div>

You can pass a function to `unique` in order to get the indices of the unique elements:

```julia
idx = unique(z -> x[z], 1:length(x))
x[idx]

```

---

_[View the full topic](https://discourse.julialang.org/t/unique-indices-method-similar-to-matlab/34446)._
