overlapadd.m

来自「基于双线性变换法的IIR滤波器范例 该滤波器为低通原型 可根据需要自行转换成高通」· M 代码 · 共 33 行

M
33
字号
function [yn] = overlapadd(xn,hn,M)
N = length(hn);
N1 = length(xn);
p = N1/M;
x = zeros(1,M);
y = zeros(p+1,M);
z = zeros(p+1,N1+M-1);
%split input xn into M points segment and store in matrix y
for k = [0:1:p-1]
    x = xn(M*k+1:M*(k+1));
    y(k+1,:) = x;
end
%handle the leaving elements of xn and add zeros to satisfy
%each segment with M points
if N1>M*(k+1)
    l = 1;
    for i = [M*(k+1)+1:N1]
        y(k+2,l) = xn(i);
        l = l+1;
    end
end
%conv hn and new input then shift and store the result in a new matrix z
b=0;
for j = [1:p+1]
    z(j,b*M+1:b*M+N+M-1) = conv(y(j,:),hn);
    b=b+1;
end
%add each row of z so the last row will be the final result
for j = [1:p]
    z(j+1,:) = z(j,:)+z(j+1,:)
end
yn = z(j+1,:)

⌨️ 快捷键说明

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