Chinaunix首页 | 论坛 | 博客
  • 博客访问: 70984
  • 博文数量: 25
  • 博客积分: 880
  • 博客等级: 准尉
  • 技术积分: 245
  • 用 户 组: 普通用户
  • 注册时间: 2008-07-05 10:27
文章分类

全部博文(25)

文章存档

2011年(1)

2009年(2)

2008年(22)

我的朋友

分类:

2008-07-05 11:02:32

FIR Lowpass Filter Design In Window Functions

BY JingFeng ZhaoEE

 

Typical procedure of design lowpass filter in windows:

To design a lowpass filter in windows, we should do in this procedure:

(1)   Get hd(n), here exists three different situations:

①If we know desired frequency response Hd(ω), we just need to compute IDTFT{ Hd(ω) = hd(n)};

②If we know desired frequency response Hd(ω), but it is very complex, or we cannot write a determinate formula for Hd(ω), we can sample M points in Hd(ω), then take M point IDTFT{ Hd(ω)}

③If we just know the stopband attenuation and the desired boundary frequency, we can use ideal filter as approximating function, then take IDTFT for this approximating function to get hd(n).

(2) After we get hd(n), we should determine the window function(ω(n)) according to the desire of Transition band and the stopband attenuation.

(3) h(n) = hd(n) ω(n). Where ω(n) is finite length window function.

 

Design In MATLAB

In the preamble, I have related to the typical way of design a lowpass filter by window function. If we make a program in C language in this method, we can design the filter we needed, but it is not necessary just because we have MATLAB, with MATLAB, the design will be very easy.

Here I choose remez arithmetic. It relates to functions:

①remezord(), with this function we can get the order of filter.

②remez(), use this function we can get a sequence, actually this sequence is h(n).

Here we find the power of science computing software(such as MATLAB and SCILAB)! Yes, it make the design to be very easy and happy!

 

Here is all the source code of my design:

clear

Fs=8000;

fp=0.2*Fs/2

rp=1-10^(-0.25/20);

fs=0.3*Fs/2

rs=10^(-51/20)

f=[fp fs];

A=[1 0];

dev=[rp rs];

[n,f0,m0,w]=remezord(f,A,dev,Fs);

n

b=remez(n,f0,m0,w);

freqz(b,1,256)

%[h,w]=freqz(b,1,256,1);

%h=abs(h);

%h=20*log10(h);

%plot(w,h);

%xlabel('频率(归一化)');

%ylabel('幅度(db)');

t = (0:200)/8000;

s = sin(2*pi*t*400)+sin(2*pi*t*1500);%混和正弦波信号

sf = filter(b,1,s);

figure(2);

subplot(211)

plot(t,s);

grid on;

%xlim([0,1]);

%ylim([-4,4]);

subplot(212)

plot(t,sf);

grid on;

%xlim([0,1]);

%ylim([-4,4])

阅读(1010) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~