corr.m

来自「基于Matlab的地震数据处理显示和测井数据显示于处理的小程序」· M 代码 · 共 27 行

M
27
字号
function c = corr(a,b)
%   Correlation of vectore "a" and "b". The resulting
%   vector is length length(a)+length(b)-1
%
na = length(a);
nb = length(b);

if na ~= numel(a) | nb ~= numel(b)
   error('"a" and "b" must be vectors.');
end

% "filter" is substantially faster if the first argument to filter
%  the shorter of the two.
if na > nb
    if nb > 1
        a(na+nb-1)=0;
    end
    c=filter(b(end:-1:1),1,a);
else
    if na > 1
        b=b(end:-1:1);
        b(na+nb-1)=0;
    end
    c=filter(a,1,b);
end

⌨️ 快捷键说明

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