Index of a grid

Hmm do you want something like a matrix of only the selected terms and everything else zero? If so, then:

julia> Ynew = zeros(5,5)
5×5 Matrix{Float64}:
 0.0  0.0  0.0  0.0  0.0
 0.0  0.0  0.0  0.0  0.0
 0.0  0.0  0.0  0.0  0.0
 0.0  0.0  0.0  0.0  0.0
 0.0  0.0  0.0  0.0  0.0

julia> Ynew[inds] .= Y[inds];

julia> Ynew
5×5 Matrix{Float64}:
  0.0   0.0   0.0   0.0   0.0
 16.0  11.0  12.0   0.0  11.0
 13.0  20.0   0.0   0.0   0.0
  0.0   0.0   0.0  12.0   0.0
 15.0  13.0  15.0   0.0   0.0

Otherwise, what Y[inds] does is return a vector of all the values in Y that match your criterion. That is, inds is a vector of indices that match your criterion and then you get a vector out of Y of those corresponding indices. Does this make sense?

1 Like