0% found this document useful (0 votes)
49 views

Design Filters Using Matlab

This document describes how to design filters using Matlab. It provides examples of low pass, high pass, band pass, and band stop filters. For each filter type, it gives the parameters needed such as sampling frequency, filter order, cutoff frequencies, and shows how to use the butter and filter functions to create the filter and apply it to a sample input signal. Frequency response plots are also generated using freqz to analyze the filters.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
49 views

Design Filters Using Matlab

This document describes how to design filters using Matlab. It provides examples of low pass, high pass, band pass, and band stop filters. For each filter type, it gives the parameters needed such as sampling frequency, filter order, cutoff frequencies, and shows how to use the butter and filter functions to create the filter and apply it to a sample input signal. Frequency response plots are also generated using freqz to analyze the filters.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 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