fir_iir.m

来自「这是一个用于语音信号处理的工具箱」· M 代码 · 共 31 行

M
31
字号
% fir_iir.m

function [ptr_output,ptr_delay]=fir_iir(ptr_delay,input,cnst,index)
% first order FIR or IIR filter

if index==0,

% double fir(ptr,input,cnst)
% simulate the equation y(n) = a*x(n-1) + x(n),
% where cnst = a, delay = x(n-1) and input = x(n).
% zero is located at z = a, i.e., on the positive real axis 
 
	ptr_input = input;
	ptr_output = ptr_input + cnst*ptr_delay; % summaton 
	ptr_delay = input;  % send data through delay i.e., x(n-1) = x(n) 
end

if index==1,

% double iir(ptr, input, cnst)
% simulate the equation y(n) = a*y(n-1) + x(n),
% where cnst = a, delay = y(n-1) and input = x(n).
% pole is located at z = a, i.e., on the positive real axis 
 
	ptr_input = input;   
	ptr_output = ptr_input + cnst*ptr_delay; % summaton 

	% send data through delay i.e., y(n-1) = y(n) 
	ptr_delay = ptr_output;
end

⌨️ 快捷键说明

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