I have a matrix a(16x3) and a vector b(16x1). b shows how many of the values in the matrix a are valid per row.
a = magic(3)
a =
8 1 6
3 5 7
4 9 2
b = [1;3;2]
b =
1
3
2
What I'm trying to do is setting the invalid values to NaN:
a(:,b+1:end)=NaN
Result is:
a =
8 NaN NaN
3 NaN NaN
4 NaN NaN
But what I would have expected is:
a =
8 NaN NaN
3 5 7
4 9 NaN
What is wrong here?