I have a bunch of values in a 3-dimensional matrix, and I am finding the mean value of them:
mean(mean(mat))
Now, of different reasons I have to append some rows and elements to the matrix. But I want the mean value to stay the same – as if the added elements are neutral and do not inflict in the result.
Like when you multiply a bunch of values, you can multiply additional 1’s without changing the result. And with addition you can add further 0’s with no inflict.
What kind of value in Matlab can I assign to the new elements in the matrix to make the elements neutral when using the mean()?
Note added
The point is, when I am calculating the mean value I only have the new resized matrix to do it from. Therefore the added elements must be neutral.
I am thinking of something like NaN, but I had no luck with that since the mean value then also end up as NaN.
Adding values equal to the mean of the matrix without the added values will leave the new mean the same. (I hope that makes sense!). Point is to fill in and not change the new mean, use the current mean.
Alternatively, you can fill in with NaN and use the
nanmeanfunction.