scale.m

来自「实现地震勘探中」· M 代码 · 共 29 行

M
29
字号
function [scaled,scale]=scale(a,b,type)
% Function scales columns of a so that they best match b.
% a and b must have the same number of columns.
% type indicates if one scale for all column is to be computed (type=1)
% or if each column should be scaled separately (any other value)
%
%	[scaled,scale]=scale(a,b,type)

ma=size(a,2); 
mb=size(b,2);
if ma ~= mb, 
   fprintf('ERROR in scale: input arrays have different number of columns (%d, %d)\n',ma,mb)
   return
end

cc=correlate(a,b); 
mcc=max(cc);
ac=sum(a.*a);
if type == 1,
   scale=sum(mcc,2)/sum(ac,2);
   scaled=scale*a;
else
   scale=mcc./ac;
   scaled=zeros(size(a));
   for ii=1:size(a,2);
      scaled(:,ii)=a(:,ii)*scale(ii);
   end
end

⌨️ 快捷键说明

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