# Findall() but returning a bool array

**URL:** <https://discourse.julialang.org/t/findall-but-returning-a-bool-array/65934>\
**Category:** General Usage\
**Tags:** question\
**Created:** [August 6, 2021, 9:46am UTC](https://discourse.julialang.org/t/findall-but-returning-a-bool-array/65934 "2021-08-06T09:46:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Valery](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/valery/32/21803_2.png) [@Valery](https://discourse.julialang.org/u/Valery)\
**Post date:** [August 6, 2021, 9:46am UTC](https://discourse.julialang.org/t/findall-but-returning-a-bool-array/65934/1 "2021-08-06T09:46:44Z")

</div>

Hi all,

I would have liked the `findall()` function to return booleans.

Code example:

```julia
A = [1 2; 3 4]
B = findall(>(2),A)
C = [0 0; 1 1]
B == C

```

This code will obviously return false at the `B==C` assertion. What should I use if I want `B` to be an array of the same dimension as `A` but containing booleans (0 for this coordinate does not satisfy the condition, 1 for this coordinate satisfies the condition).

Thank you for your attention.

EDIT: I made a comparison with matlab that was wrong. Thus I deleted the sentence.

---

<div class="post-metadata">

**Author:** ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)\
**Post date:** [August 6, 2021, 9:48am UTC](https://discourse.julialang.org/t/findall-but-returning-a-bool-array/65934/2 "2021-08-06T09:48:27Z")

</div>

> [@Valery](#):
>
> `B = findall(>(2),A)`

```julia
B = A .> 2

```

?

---

<div class="post-metadata">

**Author:** ![DNF](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dnf/32/10191_2.png) [@DNF](https://discourse.julialang.org/u/DNF)\
**Post date:** [August 6, 2021, 10:12am UTC](https://discourse.julialang.org/t/findall-but-returning-a-bool-array/65934/3 "2021-08-06T10:12:38Z")

</div>

This is Matlab code:

```julia
>> A = [1 2; 3 4]
 
>> B = find(A>2)
B =
     2
     4

>> A > 2
ans =
  2×2 logical array
   0 0
   1 1

```

In other words, Julia already behaves pretty much like Matlab does, except that `findall` returns a vector of cartesian indices instead of linear indices.

---

<div class="post-metadata">

**Author:** ![Valery](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/valery/32/21803_2.png) [@Valery](https://discourse.julialang.org/u/Valery)\
**Post date:** [August 6, 2021, 4:27pm UTC](https://discourse.julialang.org/t/findall-but-returning-a-bool-array/65934/4 "2021-08-06T16:27:08Z")

</div>

I corrected the mistake in the post where I mentioned matlab.
