I have the following matrix
A = [ 0 0
0 0
1 -1
NaN NaN
NaN NaN
0 0
NaN NaN
NaN NaN]
I want to replace all the NaN rows with the rows above it. For the matrix above, this would be
A = [0 0
0 0
1 -1
1 -1
1 -1
0 0
0 0
0 0]
I’m not sure whether this can be vectorized…the simpler solution would probably be a loop: