I have a matrix, on which the values become larger as columns go, but some values in that matrix are zero.
I want to replace the values that are zero with an interpolation. In this example theres an increment of 1 per line, so the value zero should become the previous value in that column (1) plus the average increment value (1). Therefore becoming the value 2.
Returning the matrix [1,1,1;2,2,2;3,3,3]
So how can I do this given any matrix, with whatever values.
EDIT: Okay I probably got myself misunderstood, I dont want the zero values to be always the previous value + 1. Let me illustrate further:
M = [1,10;1,0;1,0;1,22]
-Values m(2,2) and m(3,2) are both zero.
-Values m(1,2) and m(4,2) are 10 and 22 which means in 3 rows there was an increment of 12 values, averaging and increment of 4 values per row.
-Interpolating, the values for m(2,2) and m(3,2) should be 14 and 18 respectively.
Thanks alot for you help, appreciated.
No products are associated with this question.
Play games and win prizes!Learn more