Choose role of NaN when summing two matrices
Dear all
Some time ago, I posted this question: Choosing the role of NaN elements in the sum environment of matrices. That worked great when doing the mean value, but now imagine that I just want to sum the two matrices, given by:
aa=[1 2; 3 NaN];
bb=[NaN 1; 2 NaN];
so that I obtain:
cc=[1 3; 5 NaN];
If I do something like:
cc=sum(cat(3,aa,bb),3,’omitnan’)
that gives:
cc=[1 3; 5 0];
Which way would be the best in this case?Dear all
Some time ago, I posted this question: Choosing the role of NaN elements in the sum environment of matrices. That worked great when doing the mean value, but now imagine that I just want to sum the two matrices, given by:
aa=[1 2; 3 NaN];
bb=[NaN 1; 2 NaN];
so that I obtain:
cc=[1 3; 5 NaN];
If I do something like:
cc=sum(cat(3,aa,bb),3,’omitnan’)
that gives:
cc=[1 3; 5 0];
Which way would be the best in this case? Dear all
Some time ago, I posted this question: Choosing the role of NaN elements in the sum environment of matrices. That worked great when doing the mean value, but now imagine that I just want to sum the two matrices, given by:
aa=[1 2; 3 NaN];
bb=[NaN 1; 2 NaN];
so that I obtain:
cc=[1 3; 5 NaN];
If I do something like:
cc=sum(cat(3,aa,bb),3,’omitnan’)
that gives:
cc=[1 3; 5 0];
Which way would be the best in this case? summing matrices, role of nan MATLAB Answers — New Questions