Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

Design filters using Matlab

By:
Anwer Sabah
Ali Falah
Ammar Ahmed
Arkan Maitham
Hassan Saeed
Hussein Abd Al-Hadi
Mujtaba M.Hussein
Mohammed Yahya

1- Low Pass Filter "LPF":Fs: simple frequency.


Fn: nyquist frequency.
n: the filter order.
wn: the filtering frequencies.
P: no. of elements of the array.
Q: no. of rows .
Type: 'LPF' .

fs= ;
fn=fs/2;
x=randn(p,q);
[b,a]=butter(n,wn/fn,'type');
y=filter(b,a,x)
freqz(b,a, number of poins,fs)
Example1:fs=1500;
fn=fs/2;
x=randn(1000,1);
[b,a]=butter(4,50/fn);
y=filter(b,a,x);
figure(1)
freqz(b,a,1000,fs)

Example2:fs=1500;
fn=fs/2;
t=0:1/fs:0.5;
x=cos(2*pi*500*t);
[b,a]=butter(6,500/fn);
y=filter(b,a,x);
figure(1)
freqz(b,a,1000,fs)

2- High Pass Filter "HPF":Fs: simple frequency.


Fn: nyquist frequency.
n: the filter order.
wn: the filtering frequencies.
P: no. of elements of the array.
Q: no. of rows .
Type: 'HPF' .

fs= ;
fn=fs/2;
x=randn(p,q);
[b,a]=butter(n,wn/fn,'type');
y=filter(b,a,x)
freqz(b,a, number of poins,fs)

Example1:fs=1500;
fn=fs/2;
x=randn(1000,1);
[b,a]=butter(6,150/fn,'high');
y=filter(b,a,x);
figure(1)
freqz(b,a,1000,fs)

Example2:fs=1500;
fn=fs/2;
t=0:1/fs:0.5;
x=cos(2*pi*400*t);
[b,a]=butter(6,150/fn,'high');
y=filter(b,a,x);
figure(1)
freqz(b,a,1000,fs)

3- Band Pass Filter "BPF":Fs: simple frequency.


Fn: nyquist frequency.
n: the filter order.
wn: the filtering frequencies=[wn1 wn2].
P: no. of elements of the array.
Q: no. of rows .
Type: 'BPF' .

fs= ;
fn=fs/2;
x=randn(p,q);
[b,a]=butter(n,wn/fn,'type');
y=filter(b,a,x)
freqz(b,a, number of poins,fs)
Example1:fs=1000;
fn=fs/2;
x=randn(1000,1);
[b,a]=butter(4,[400 450]/fn,'bandpass');
y=filter(b,a,x);
figure(1)
freqz(b,a,1000,fs)

Example2:fs=1000;
fn=fs/2;
t=0:1/fs:0.5;
x=cos(2*pi*50*t);
[b,a]=butter(4,[25 75]/fn,'bandpass');
y=filter(b,a,x);
figure(1)
freqz(b,a,1000,fs)

4- Band Stop Filter "PSF":Fs: simple frequency.


Fn: nyquist frequency.
n: the filter order.
wn: the filtering frequencies=[wn1 wn2].
P: no. of elements of the array.
Q: no. of rows .
Type: 'PSF' .

fs= ;
fn=fs/2;
x=randn(p,q);
[b,a]=butter(n,wn/fn,'type');
y=filter(b,a,x)
freqz(b,a, number of poins,fs)
Example1:fs=1000;
fn=fs/2;
x=randn(1000,1);
[b,a]=butter(4,[150 250]/fn,'stop');
y=filter(b,a,x);
figure(1)
freqz(b,a,1000,fs)

Example2:fs=1000;
fn=fs/2;
t=0:1/fs:0.5;
x=cos(2*pi*100*t);
[b,a]=butter(4,[100 200]/fn,'stop');
y=filter(b,a,x);
figure(1)
freqz(b,a,1000,fs)

You might also like