⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 corr2.m

📁 有关matlab的电子书籍有一定的帮助希望有用
💻 M
字号:
function r = corr2(a,b)
%CORR2 Compute 2-D correlation coefficient.
%   R = CORR2(A,B) computes the correlation coefficient between A
%   and B, where A and B are matrices or vectors of the same size.
%
%   See also CORRCOEF, STD2.

%   Clay M. Thompson 10-6-92
%   Copyright 1993-1998 The MathWorks, Inc.  All Rights Reserved.
%   $Revision: 5.7 $  $Date: 1997/11/24 15:34:25 $

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

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

if (~isa(a,'double'))
    a = double(a);
end

if (~isa(b,'double'))
    b = double(b);
end

a = a - mean2(a);
b = b - mean2(b);

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

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -