Path: news.mathworks.com!not-for-mail
From: "Tom Lane" <tlane@mathworks.com>
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$1@newscl01ah.mathworks.com>
References: <jhmdpm$8v6$1@newscl01ah.mathworks.com>
Reply-To: "Tom Lane" <tlane@mathworks.com>
NNTP-Posting-Host: ah-tlane.dhcp.mathworks.com
Mime-Version: 1.0
Content-Type: text/plain;
	format=flowed;
	charset="UTF-8";
	reply-type=response
Content-Transfer-Encoding: 7bit
X-Trace: newscl01ah.mathworks.com 1329517600 297 172.31.57.151 (17 Feb 2012 22:26:40 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 17 Feb 2012 22:26:40 +0000 (UTC)
In-Reply-To: <jhmdpm$8v6$1@newscl01ah.mathworks.com>
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: news.mathworks.com 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