I am trying to replace an array with another array, but only in places where the original array is zero. These arrays are equal in dimensions.
Array1 = [0, 2, 4, 2, 5, 0, 0, 2, 5]
Array2 = [1, 2, 3, 4, 5, 6, 7, 8, 9]
I am currently trying to use the code below to superimpose array2 into array 1 where array1's values are equal to zero.
Array1[Array1 .== 0] .= Array2
From this I was hoping to get the following...
Array1 = [1, 2, 4, 2, 5, 6, 7, 2, 5]
but instead I get an error...
ERROR: DimensionMismatch("array could not be broadcast to match destination")
Is there a nice way to do this without looping through each list/array one element at a time? I am working with really large arrays and don't know if that would be too slow. Any help is appreciated.