MATLAB: Does NaN used in confusion matrix affects results

confusion matrixnan

I have used confusion matrix and for making two matrices of equal dimensions I had used NaN but is it wise to use that? for example: A= [2 3 7 ]; B= [3 4 NaN]; C= A+B; C= 5 7 NaN I am getting where result should have been [5 7 7] according to me.Can anyone help? Thanx in advance.

Best Answer

Here's one way:
C = nansum([A; B])
C =
5 7 7