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

📄 correlation.m

📁 地震、测井方面matlab代码,解释的比较详细
💻 M
字号:
function c = correlate(a,b)
%  Function computes the correlation of the two input vectors/matrices
%  (if one of the inputs is a matrix, the other must either
%  be a vector or a matrix with the same number of columns).
%  c(k)=sum(a(i+k)*b(k))
%  The number of rows of c is the nuber of rows of a
%  plus the number of rows of b minus 1.
%  c = correlate(a,b)
%
[na,ma]=size(a);
[nb,mb]=size(b);
b=flipud(b);
if ma == 1
  if mb == 1
    c=conv(a,b);
  else
    c=zeros(na+nb-1,mb);
    for i=1:mb
      c(1:na+nb-1,i)=conv(a,b(:,i));
    end 
  end
elseif mb == 1
  c=zeros(1:na+nb-1,ma);
  for i=1:ma
    c(1:na+nb-1,i)=conv(a(:,i),b);
  end
elseif ma ~= mb
  ERROR = 'Input data are not compatible'
else
  c=zeros(na+nb-1,ma);
  for i=1:ma
    c(1:na+nb-1,i)=conv(a(:,i),b(:,i));
  end
end
  

⌨️ 快捷键说明

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