nansum

nansum — sum ignoring Nan's

Calling sequence

s=nansum(x)  
s=nansum(x,'r') (or s=nansum(x,1))  
s=nansum(x,'c') (or s=nansum(x,2))  

Parameters

x : real or complex vector or matrix

Description

This function returns in scalar or vector s the sum of the values (ignoring the NANs) of a vector or matrix x.

For a vector or matrix x, s=nansum(x) returns in scalar s the sum of all the entries (ignoring the NANs) of x.

s=nansum(x,'r')(or, equivalently, s=nansum(x,1)) returns in each entry of the row vector s of type 1xsize(x,'c') the sum of each column of x (ignoring the NANs).

s=nansum(x,'c')(or, equivalently, s=nansum(x,2)) returns in each entry of the column vector s of type size(x,'c')x1 the sum of each row of x (ignoring the NANs).

In Labostat, NAN values stand for missing values in tables.

Examples




x=[0.2113249 %nan 0.6653811;0.7560439 0.3303271 0.6283918]
m=nansum(x)
m=nansum(x,1)
m=nansum(x,2)
 
  

Author

Carlos Klimann

Biblio

Wonacott, T.H. & Wonacott, R.J.; Introductory Statistics, fifth edition, J.Wiley & Sons, 1990.