Undef to zeros?

Hi all.
I have this array that was a lot info on it. Some of the cells in the matrix are "#undef "
I want to write the file to ascii… any way to change all the #undef to zeros, or something?
Thanks!

you can achieve this by initializing the matrix to be all zeros instead of trying to find and replace #undef. How did you obtain such a matrix to begin with?

1 Like

Something like this?

for i in eachindex(x)
    if !isassigned(x, i)
        x[i] = 0
    end
end
2 Likes

you might want zero(eltype(x))

1 Like

Perfect! Thanks!