From: "Tom Lane" <>
Newsgroups: comp.soft-sys.matlab
Subject: Re: n for each 'pairwise' correlation in corrcoef
Date: Fri, 17 Feb 2012 17:26:40 -0500
Organization: MathWorks
Lines: 16
Message-ID: <jhmk70$99$>
References: <jhmdpm$8v6$>
Reply-To: "Tom Lane" <>
Mime-Version: 1.0
Content-Type: text/plain;
Content-Transfer-Encoding: 7bit
X-Trace: 1329517600 297 (17 Feb 2012 22:26:40 GMT)
NNTP-Posting-Date: Fri, 17 Feb 2012 22:26:40 +0000 (UTC)
In-Reply-To: <jhmdpm$8v6$>
X-Priority: 3
X-MSMail-Priority: Normal
Importance: Normal
X-Newsreader: Microsoft Windows Live Mail 14.0.8089.726
X-MimeOLE: Produced By Microsoft MimeOLE V14.0.8089.726
Xref: comp.soft-sys.matlab:758075

> I need to extract the number of 'pairwise' observations on which each 
> correlation in the correlation coefficient matrix is based. I have looked 
> at the help document, but it doesn't look as if there is a parameter to 
> extract n.
> Any suggestions of a workaround?

I believe this will work. At least it seems to work in my example.

x = rand(10,4)   % generate some data
x(6:6:end) = nan    % sprinkle some NaNs into it
notnan = double(~isnan(x))   % find non-NaN values
notnan'*notnan  % find number of matching non-NaN values

-- Tom