官方淘宝店 易迪拓培训 旧站入口
首页 > 无线通信 > 通信技术学习讨论 > 请问,这个滤波器m语言怎么写

请问,这个滤波器m语言怎么写

12-16
RT

% 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.

Top