请问,这个滤波器m语言怎么写
% one example, you need make some modifications before use it.
% w is the taps of filter
% c is the input signal c(n)
% b is the output signal b(n)
b=function myfilter(c,w)
len=length(w);
reg=zeros(1,len);
half_len = ceil(len/2);
for i=1:length(c)
y=c(i)+sum(reg(1:half_len)w(half_len+2:len));
b(i)=sum(regw);
reg=[max([y 0]) reg(1:end-1)];
end
thx!
每次调用该函数,都初始化reg=0, 这样有没有问题?输入c是一帧,但有多个连续帧需要处理。
可定义reg为全局变量么? 初始为0
yes, you can choose following methods:
1. set global parameter reg or
2. initial parameter reg in main function then add one output parameter reg and one input parameter reg in the myfilter function, such as
reg = 0;
for i=1:N frame
[b(i),reg]= myfilter(c(i),w,reg)
end
3. don't use myfilter function, write the filter code in the main function directly.
it depends on you.
相关文章:
- Re: 求教:FIR滤波器与IIR滤波器的区别(05-08)
- 关于接收滤波器的问题(05-08)
- 请问均衡滤波器电路是怎么实现的(05-08)
- 成形滤波器的困惑(05-08)
- 关于下变频和带通滤波器(05-08)
- 什么是滤波器群延迟?(05-08)