binsmooth.m

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

M
64
字号
function avin=binsmooth(in,dist)% Function computes a binomial-weighted average over "dist" samples of the % columns of matrix "in". "dist" must be greater than or equal to 1 and should% be an odd integer% SEE ALSO: smooth, anysmooth%% Written by: E. R.:% Last updated: July 9, 2003: modified end condition to assure that mean of columns is not changed%%        avin=binsmooth(in,dist)% INPUT% in     matrix whose columns should be smoothed% dist   "distance" in terms of samples over which to average% OUTPUT% avout  matrix with averaged columns (same size as "in"). At both ends of the column%        vectors the averaging is performed over fewer samples%% EXAMPLE%         a=[1,0,0,0,1,0,0,0,1]'; as=binsmooth(a,3)        if dist == 1   avin=in;   returnend[n,m]=size(in);if n == 1   in=in.';   [n,m]=deal(m,n);   flip=1;else   flip=0;end%       Create an odd smoothing filteridist=2*fix((dist-1)/2);weights=binom(idist,idist+1)/2^idist;if length(weights) > n   avin=mean(in);   avin=avin(ones(n,1),:);   returnendappend=idist/2;avin=zeros(size(in));for ii=1:m   temp1=conv(in(:,ii),weights);   avin(:,ii)=temp1(append+1:end-append);end%       Repair wrong scaling at ends of data setsfor ii=1:append   fact=sum(weights(1:idist/2+1-ii));   avin(ii,:)=avin(ii,:)+in(ii,:)*fact;   avin(end-ii+1,:)=avin(end-ii+1,:)+in(end-ii+1,:)*fact;endif flip   avin=avin.';end

⌨️ 快捷键说明

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