# Find indexes of a String in Multi -Type Matrix

**URL:** <https://discourse.julialang.org/t/find-indexes-of-a-string-in-multi-type-matrix/128072>\
**Category:** General Usage\
**Tags:** indexing, arrays, undef\
**Created:** [April 14, 2025, 6:43pm UTC](https://discourse.julialang.org/t/find-indexes-of-a-string-in-multi-type-matrix/128072 "2025-04-14T18:43:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vasilis\_Dim](https://avatars.discourse-cdn.com/v4/letter/v/6bbea6/32.png) [@Vasilis\_Dim](https://discourse.julialang.org/u/Vasilis_Dim)\
**Post date:** [April 14, 2025, 6:43pm UTC](https://discourse.julialang.org/t/find-indexes-of-a-string-in-multi-type-matrix/128072/1 "2025-04-14T18:43:08Z")

</div>

Hello There!  
I have created a matrix such as:

```julia
T=Union{String, Int}
June=Matrix{T}(undef,10,30)

```

Later in the code some entries of A might change to a string (let’s say “Bill”). I tried to locate the indexes where that’s happening using findall but it doesn’t work:

```julia
indexes=findall(x-> x=="Bill",A) 
ERROR: UndefRefError: access to undefined reference
Stacktrace:
  [1] getindex
    @ ./essentials.jl:14 [inlined]
  [2] getindex
    @ ./multidimensional.jl:696 [inlined]
  [3] _broadcast_getindex
    @ ./broadcast.jl:675 [inlined]
  [4] _getindex
    @ ./broadcast.jl:705 [inlined]
  [5] _broadcast_getindex
    @ ./broadcast.jl:681 [inlined]
  [6] getindex
    @ ./broadcast.jl:636 [inlined]
  [7] macro expansion
    @ ./broadcast.jl:1022 [inlined]
  [8] macro expansion
    @ ./simdloop.jl:77 [inlined]
  [9] copyto!
    @ ./broadcast.jl:1021 [inlined]
 [10] copyto!
    @ ./broadcast.jl:956 [inlined]
 [11] copy
    @ ./broadcast.jl:928 [inlined]
 [12] materialize(bc::Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{…}, Nothing, typeof(==), Tuple{…}})
    @ Base.Broadcast ./broadcast.jl:903
 [13] top-level scope
    @ REPL[21]:1

```

Any ideas?

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [April 14, 2025, 7:10pm UTC](https://discourse.julialang.org/t/find-indexes-of-a-string-in-multi-type-matrix/128072/2 "2025-04-14T19:10:26Z")

</div>

I think you need the following logic:

```julia
indices = filter(i -> isassigned(A, i) && (A[i]=="Bill"), CartesianIndices(A))

```

---

<div class="post-metadata">

**Author:** ![rocco\_sprmnt21](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rocco_sprmnt21/32/20127_2.png) [@rocco\_sprmnt21](https://discourse.julialang.org/u/rocco_sprmnt21)\
**Post date:** [April 14, 2025, 7:20pm UTC](https://discourse.julialang.org/t/find-indexes-of-a-string-in-multi-type-matrix/128072/3 "2025-04-14T19:20:36Z")

</div>

in other words (what Rafael formally explained)  
if you have some undefined value in the array, the findx function cannot do the comparison to understand whether the data is what you are looking for or not
