Given the code
foo(x,y) = x+y
xvec = range(0,1,length=5)
yvec = range(0,1,length=5)
fvec = vec(foo.(xvec,yvec'))
Q1: how to find indices on fvec that correspond to start/end point of xvec/yvec ?
Q2: how to overwrite values of fvec that correspond to start/end point of xvec/yvec ?
Thx!
Vectors are column vectors in Julia. Hence, in foo.(xvec, yvec')
, the first column correspond to the first element of xvec
, and the first row correspond to the first element of yvec
.
Since matrices are column-ordered in Julia, that means the indices 1:5
correspond to the start point of xvec
, 21:25
to the last point, 1:5:21
the first point of yvec
, 5:5:25
the last point of yvec
.
To overwrite them with 19
, you could do e.g. fvec[1:5:21] .= 19