Possible Duplicate:
Dealing with NaN’s in matlab functions
Is there a one line command that allows you to take the elementwise average of a matrix (ignoring NaN‘s) in Matlab? For example,
>> A = [1 0 NaN; 0 3 4; 0 NaN 2]
A =
1 0 NaN
0 3 4
0 NaN 2
So the mean(A) should equal (1+3+2+4+0+0+0)/7 = 1.4286
Also, I don’t have access to the stats toolbox so I cannot use nanmean()
You can use
isnan()to filter out the unwanted elements: