Pages

Showing posts with label LOW PASS FILTER. Show all posts
Showing posts with label LOW PASS FILTER. Show all posts

Wednesday, April 27, 2011

DESIGN FIR LOWPASS FILTER WITH CUTOFF FREQUENCY 0.5*pi using RECTANGULAR WINDOW

clear all;
wcutoff=input('ENTER THE CUT OFF FREQUENCY in radians eg: 0.5*pi--->');
N=input('ENTER THE NUMBEROF SAMPLES eg: N=25--->');
alpha=(N-1)/2;
epso=.001;          %to prevent singularity when n=alphan=0:1:N-1;
hd=sin(wcutoff*(n-alpha+epso))./(pi*(n-alpha+epso));
                              %expression for FIR Lowpass filterwr=boxcar(N);       %expression for Rectangular window
hn=hd.*wr';            %wr'=transpose of wr
w=0:0.01:pi;
h=freqz(hn,1,w);    %MATLAB function for frequency response
xlabel('Normalised frequency \omega/\pi');
ylabel('Magnitude');
plot(w/pi,abs(h));  %to plot the graph


OUTPUT

ENTER THE CUT OFF FREQUENCY in radians eg: 0.5*pi--->0.5*pi
ENTER THE NUMBER OF SAMPLES eg: N=25--->31

PLOT


FIR LOWPASS FILTER USING RECTANGULAR WINDOW

Monday, December 13, 2010

MATLAB PROGRAM FOR IMPLEMENTING CHEBYSHEV LOW PASS FILTER


%chebyshev LPF
% specification
clear all;
alphap=input('pass band attenuation?=');
alphas=input('stop band attenuation in db?=');
wp=input('pass band frq in rad=');
ws=input('stop band freq in rad=');
% find cut-off freq and order of filter
[n,wn]=cheb1ord(wp/pi,ws/pi,alphap,alphas);
%system function above
[b,a]=cheby1(n,alphap,wn);
w=0:.01:pi;
[h,ph]=freqz(b,a,w);m=20*log(abs(h));
an=angle(h);
subplot(221);
plot(ph/pi,m);
grid;
ylabel('gain in db');
xlabel('nor fre');
subplot(212);
plot(ph/pi,an);
grid;
ylabel('phase in rad');
xlabel('norm freq');
 
 
OUTPUT WAVEFORM