%% NaN Values
% Create a normally distributed matrix involving NaN values, and compute the correlation coefficient matrix, excluding any rows that contain NaN.

A = randn(5,3);
A(1,3) = NaN;
A(3,2) = NaN;
A

%

R = corrcoef(A,'Rows','complete')

%
% Use 'all' to include all NaN values in the calculation.

R = corrcoef(A,'Rows','all')

%
% Use 'pairwise' to compute each two-column correlation coefficient on a pairwise basis. If one of the two columns contains a NaN, that row is omitted.

R = corrcoef(A,'Rows','pairwise')

% Copyright 2012 The MathWorks, Inc.