person
 10:31 AM Implementation of FIR filters with Matlab code AIM: To verify FIR filters.   EQUIPMENTS: Constructor – MATLAB Software Learning Objectives: To make the students familiar with designing concepts of FIR filter with the use of MATLAB. THEORY: A Finite Impulse Response (FIR) filter is a discrete linear time-invariant system whose output is based on the weighted summation of a finite number of past inputs. An FIR transversal filter structure can be obtained directly from the equation for discrete-time convolution. In this equation, x(k) and y(n) represent the input to and output from the filter at time n.h(n-k) is the transversal filter coefficients at time n. These coefficients are generated by using FDS (Filter Design Software or Digital filter design package). FIR – filter is a finite impulse response filter. Order of the filter should be specified. Infinite response is truncated to get finite impulse response. placing a window of finite length does this. Types of windows available are Rectangular, Barlett, Hamming, Hanning, Blackmann window etc. This FIR filter is an all zero filter. PROGRAM: %fir filter design window techniques clc; clear all; close all; rp=input('enter passband ripple'); rs=input('enter the stopband ripple'); fp=input('enter passband freq'); fs=input('enter stopband freq'); f=input('enter sampling freq '); wp=2*fp/f; ws=2*fs/f; num=-20*log10(sqrt(rp*rs))-13; dem=14.6*(fs-fp)/f; n=ceil(num/dem); n1=n+1; if(rem(n,2)~=0) n1=n; n=n-1; end c=input('enter your choice of window function 1. rectangular 2. triangular 3.kaiser: \n '); if(c==1) y=rectwin(n1); disp('Rectangular window filter response'); end if (c==2) y=triang(n1); disp('Triangular window filter response'); end if(c==3) y=kaiser(n1); disp('kaiser window filter response'); end %LPF b=fir1(n,wp,y); [h,o]=freqz(b,1,256); m=20*log10(abs(h)); subplot(2,2,1);plot(o/pi,m); title('LPF'); ylabel('Gain in dB-->'); xlabel('(a) Normalized frequency-->'); %HPF b=fir1(n,wp,'high',y); [h,o]=freqz(b,1,256); m=20*log10(abs(h)); subplot(2,2,2);plot(o/pi,m); title('HPF'); ylabel('Gain in dB-->'); xlabel('(b) Normalized frequency-->'); %BPF wn=[wp ws]; b=fir1(n,wn,y); [h,o]=freqz(b,1,256); m=20*log10(abs(h)); subplot(2,2,3);plot(o/pi,m); title('BPF'); ylabel('Gain in dB-->'); xlabel('(c) Normalized frequency-->'); %BSF b=fir1(n,wn,'stop',y); [h,o]=freqz(b,1,256); m=20*log10(abs(h)); subplot(2,2,4);plot(o/pi,m); title('BSF'); ylabel('Gain in dB-->'); xlabel('(d) Normalized frequency-->') RESULTS: .u-star-rating-17 { list-style:none; margin:0px; padding:0px; width:85px; height:17px; position:relative; background: url('/.s/t/1810/rating_13.png') top left repeat-x } .u-star-rating-17 li{ padding:0px; margin:0px; float:left } .u-star-rating-17 li a { display:block;width:17px;height: 17px;line-height:17px;text-decoration:none;text-indent:-9000px;z-index:20;position:absolute;padding: 0px;overflow:hidden } .u-star-rating-17 li a:hover { background: url('/.s/t/1810/rating_13.png') left center;z-index:2;left:0px;border:none } .u-star-rating-17 a.u-one-star { left:0px } .u-star-rating-17 a.u-one-star:hover { width:17px } .u-star-rating-17 a.u-two-stars { left:17px } .u-star-rating-17 a.u-two-stars:hover { width:34px } .u-star-rating-17 a.u-three-stars { left:34px } .u-star-rating-17 a.u-three-stars:hover { width:51px } .u-star-rating-17 a.u-four-stars { left:51px } .u-star-rating-17 a.u-four-stars:hover { width:68px } .u-star-rating-17 a.u-five-stars { left:68px } .u-star-rating-17 a.u-five-stars:hover { width:85px } .u-star-rating-17 li.u-current-rating { top:0 !important; left:0 !important;margin:0 !important;padding:0 !important;outline:none;background: url('/.s/t/1810/rating_13.png') left bottom;position: absolute;height:17px !important;line-height:17px !important;display:block;text-indent:-9000px;z-index:1 } Views: 102 | Added by: vijoriya | Tags: Implementation, FIR filters, Matlab code | Rating: 0.0/0 