Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

find() function with user defined conditions #4127

Closed
abhijithch opened this issue Aug 22, 2013 · 3 comments
Closed

find() function with user defined conditions #4127

abhijithch opened this issue Aug 22, 2013 · 3 comments

Comments

@abhijithch
Copy link

Hi, I am a MATLAB user, now trying out JULIA. So most of my issues are functionalities which are in MATLAB and it would be nice to have them in JULIA as well.
Is there any way I can do the find() on vectors or matrices with conditions other than just finding nonzeros.

If find(f,A) is meant for this, the documentation is not very clear about it.

@ihnorton
Copy link
Member

Yes:

julia> a = [ 1 2 3 4 3 5 3 6 7 8 9 3 ]
julia> find( x->(x == 3), a)
4-element Array{Int64,1}:
  3
  5
  7
 12

@pao
Copy link
Member

pao commented Aug 22, 2013

You don't need the lambda:

julia> a = [ 1 2 3 4 3 5 3 6 7 8 9 3 ]
1x12 Int64 Array:
 1  2  3  4  3  5  3  6  7  8  9  3
julia> find(a .== 3)
4-element Int64 Array:
  3
  5
  7
 12

@pao
Copy link
Member

pao commented Aug 22, 2013

Also, it's worth mentioning we have an active mailing list/Google Group which is a perfect forum for questions like this at https://groups.google.com/forum/#!forum/julia-users, which I encourage you to check out!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants