function r = corr2(a,b)
%CORR2	Two-dimensional correlation coefficient.
%	CORR2(A,B) returns the 2-D correlation coefficient between
%	the matrices A and B.  A and B must be the same size.
%
%	See also STD2.

%	Clay M. Thompson 10-6-92
%	Copyright (c) 1992 by The MathWorks, Inc.
%	$Revision: 1.4 $  $Date: 1993/08/10 02:20:04 $

error(nargchk(2,2,nargin));

if any(size(a)~=size(b)), error('A and B must be the same size.'); end

r = sum(sum(a.*b))/sqrt(sum(sum(a.*a))*sum(sum(b.*b)));
