## Tuesday, 15 March 2011

### FIR filter matlab code

Matlab code for Finite impulse response (FIR) filters.

EQUIPMENTS:

Operating System         – Windows XP
Constructor                  - Simulator
Software                      - CCStudio 3 & MATLAB 7.5

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 filt 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-->');

1. With that experience, you have a better chance in landing a permanent job in a bigger hospital.
There are also those who deal with athletes who need
a private physio therapist to ascertain their health
condition in a frequent interval. A respiratory therapist has
one of the most versatile positions within the health sector.
Also see my page: http://befohyyq.9k.com/

2. However, in all of the discussion on this topic, one subject is usually overlooked.
In the same breath, some male therapists get reported by female customers who
say they (customers) were sexually harassed and handled
improperly by their therapists. As a masseuse, you also have the opportunity to earn tips.
Also see my web page > help for depression now

3. Very quickly this site will be famous among all blogging and site-building viewers,
due to it's pleasant articles

my blog - pikavippi puhelimella