Find indexes of a String in Multi -Type Matrix

Hello There!
I have created a matrix such as:

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:

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?

I think you need the following logic:

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

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