In Mathematica, I have a matrix ‘a’ with missing values and I have a matrix ‘b’ with same dimension as ‘a’. I would like to calculate a-b but if the value is missing, which I denote by ‘NA’, I would like it to remain as ‘NA’. Could you please help me with this? Please note that ‘a’ is of the dimension 1millionX300.
Thanks!
One approach would be to use a replacement rule on the result, something like this;
Another approach would be to define an
UpValuefornasuch that addition (and subtraction) involving it would always result inna; like this:UpValueswould be the way to go if you are going to do the operation more than once, replacement rules for a one-off.