SlideShare a Scribd company logo
MATLAB DSP Programs
Raja Rajasakeran
Venkat Peddigari
Pete Bernardin
Bandpass Filter
close all;
clear all;
r1 = 0.9;
r2 = 0.88;
r3=0.9;
theta1 = pi/5;
theta2 = 3*pi/10;
theta3=4*pi/10;
p1 = r1*cos(theta1) + i*r1*sin(theta1);
p2 = r1*cos(theta2) + i*r2*sin(theta2);
p3 = r3*cos(theta3) + i*r3*sin(theta3);
p2 = r2*cos(theta2) + i*r2*sin(theta2);
!aroots = [p1,conj(p1),p2,conj(p2), p3, conj(p3)];
aroots = [p2,conj(p2), p3, conj(p3)];
a = poly(aroots);
b = [1 zeros(1,18) -1];
b1 = [1];
[h,w] = freqz(b1,a);
freqzplot(h,w, 'mag');
figure;
freqzplot(h,w,'squared');
( )( ) ( )( )[ ]
( ) ( )
( ) ( )[ ]2121
4.0
21
3
3.0
21
2
1111
)4.0cos(219.0)3.0cos(219.0/1
cos219.0cos219.0/1
119.0119.0/1)(
32
3322
−−−−
=
−−
=
−−
−−−+−−−+
+−+−=






+−+−=
−−−−=
zzzz
zzzz
zezezezezH jjjj
ππ
ωω
πωπω
ωωωω
Kaiser Bessel Window
clear all;
close all;
N=61;
w31 = window(@kaiser,N,1);
w33 = window(@kaiser,N,3);
w35 = window(@kaiser,N,5);
w37 = window(@kaiser,N,7);
plot(1:N,[w31, w33, w35, w37]); axis([1 N 0 1]);
legend('beta=1','beta = 3', 'beta=5', 'beta=7');
figure;
a=[1];
[fw31,f] = freqz(w31,a);
[fw33,f] = freqz(w33,a);
[fw35,f] = freqz(w35,a);
[fw37,f] = freqz(w37,a);
freqzplot([fw31,fw33,fw35,fw37],f, 'mag');
legend('beta=1','beta = 3', 'beta=5', 'beta=7');
Time Domain Windows
clear all;
close all;
N=61;
w = window(@blackmanharris,N);
w1 = window(@hamming,N);
w2 = window(@gausswin,N,2.5);
w3 = window(@kaiser,N,5);
w4 = window(@tukeywin,N,0.5);
plot(1:N,[w1,w3,w4]); axis([1 N 0 1]);
legend('Hamming','Kaiser', 'Tukey');
figure;
a=[1];
[fw,f] = freqz(w,a);
[fw1,f] = freqz(w1,a);
[fw2,f] = freqz(w2,a);
[fw3,f] = freqz(w3,a);
[fw4,f] = freqz(w4,a);
freqzplot([fw1,fw3,fw4],f, 'mag');
legend('Hamming','Kaiser', 'Tukey');
DFT of Square Waves, 3 Duties
close all;
clear all;
x = ones(1,16);
y = fft(x,16);
my = abs(y)/16;
ay = angle(y);
stem(my);
figure;
y1 = fft (x,32)/16;
my1 = abs(y1);
stem(my1);
y2= fft (x,128);
figure;
stem (abs(y2));
100% Duty 50% Duty
12.5% Duty
Notch Filters
clear all;
close all;
a = [1 -1.2726 0.81];
b = [1 -1.414 1];
[H, W] = freqz(b,a);
figure;
freqzplot(H,W,'linear');
title ('Pole-zero Notch Filter - Mag');
figure;
freqzplot(H,W);
title ('Pole-zero Notch Filter - dB');
a1 = [1];
b1 = [1 -1.414 1];
[H1, W] = freqz(b1,a1);
figure;
freqzplot(H1,W,'linear');
title ('All zero Notch Filter - Mag');
figure;
freqzplot(H1,W);
title ('All zero Notch Filter - dB');
1 2
3 4
Resonators
clear all;
close all;
r = 0.99;
theta = pi/4;
a = [1 -2*r*theta r^2];
b = 1;
[H, W] = freqz(b,a);
figure;
freqzplot(H,W,'linear');
title ('Resonator r=0.99, theta = pi/4 - Mag');
figure;
freqzplot(H,W);
title (' Resonator r=0.99, theta = pi/4- dB');
r = 0.95;
theta = pi/4;
a = [1 -2*r*theta r^2];
b = 1;
[H, W] = freqz(b,a);
figure;
freqzplot(H,W,'linear');
title ('Resonator r=0.95, theta = pi/4 - Mag');
figure;
freqzplot(H,W);
title (' Resonator r=0.95, theta = pi/4- dB');
r = 0.99;
theta = pi/4;
a = [1 -2*r*theta r^2];
b = [1 0 -1]
[H, W] = freqz(b,a);
figure;
freqzplot(H,W,'linear');
title ('Pole-zero Resonator r=0.99, theta = pi/4 - Mag');
figure;
freqzplot(H,W);
title ('Pole-zero Resonator r=0.99, theta = pi/4- dB');
r = 0.9;
theta = pi/4;
a = [1 -2*r*theta r^2];
b = 1;
[H, W] = freqz(b,a);
figure;
freqzplot(H,W,'linear');
title ('Resonator r=0.9, theta = pi/4 - Mag');
figure;
freqzplot(H,W);
title (' Resonator r=0.9, theta = pi/4- dB');
r = 1.0;
theta = pi/4;
a = [1 -2*r*theta r^2];
b = 1;
[H, W] = freqz(b,a);
figure;
freqzplot(H,W,'linear');
title ('Oscillator, theta = pi/4 - Mag');
figure;
freqzplot(H,W);
title ('Oscillator, theta = pi/4- dB');
1
Resonators (continued)
2 43
98
765
10
Comb Filters
clear all;
close all;
a = [1 -1];
b = [1 0 0 0 0 0 0 0 0 0 0 -1];
b = b/11;
[H, W] = freqz(b,a);
figure;
freqzplot(H,W,'linear');
title ('Comb Filter M=10 - Mag');
figure;
freqzplot(H,W);
title ('Comb Filter M=10 - dB');
bz = zeros (1,54);
a1 = [1 0 0 0 0 -1];
b1 = [1 [bz] -1];
[H, W] = freqz(b1,a1);
figure;
freqzplot(H,W,'linear');
title ('LM Comb Filter L = 5 M=10 - Mag');
figure;
freqzplot(H,W);
title ('LM Comb Filter L = 5 M=10 - dB');
1 2
3 4
Welch Periodogram PSD
close all;
clear all;
t = 0:.001:4.096;
x = sin(2*pi*50*t) + sin(2*pi*120*t);
stdev = 2;
y = x + stdev*randn(size(t));
figure;
plot(y(1:50))
title('Noisy time domain signal')
FS = 1000.; % Sampling Rate
% 1 section
NFFT = 4096;
Noverlap = 0
figure;
pwelch(y, 4096, Noverlap, NFFT, FS)
% 16 overlapping sections
NFFT = 512;
Noverlap = 256
figure;
pwelch(y, 512, Noverlap, NFFT, FS)
% 32 overlapping sections
NFFT = 256;
Noverlap = 128
figure;
pwelch(y, 256, Noverlap, NFFT, FS)
¼ Hz Res
2 Hz Res 4 Hz Res
Time
1 2
43
Discrete Fourier Transform (DFT)
Forward Transform: for k=0,1,2,…,N-1
Inverse Transform: for n=0,1,2,…,N-1
-----------------------------------------------------------------------------------------------------------
N=8; % MATLAB “DISCRETE FOURIER TRANSFORM” PROGRAM
w0 = 2*pi/N;
K0 =3;
w=w0*K0*(0:N-1);
Data = complex(cos(w),sin(w)); % Data = ej2πnKo/N
for k =1:N
accum=complex(0,0);
for n=1:N
A = w0*(n-1)*(k-1);
Twiddle=complex(cos(A),-sin(A)); %Twiddle = e-j2πnk/N
accum = accum+Data(n)*Twiddle; % X(k)= Σej2πnKo/N
e-j2πnk/N
end % "n" is Time index
MAGXk=abs(accum) % Output the Magnitude of the DFT =N @ k=K0
end % "k" is the Frequency index

More Related Content

What's hot

5th Semester Electronic and Communication Engineering (June/July-2015) Questi...
5th Semester Electronic and Communication Engineering (June/July-2015) Questi...5th Semester Electronic and Communication Engineering (June/July-2015) Questi...
5th Semester Electronic and Communication Engineering (June/July-2015) Questi...
BGS Institute of Technology, Adichunchanagiri University (ACU)
 
Jarrar.lecture notes.aai.2011s.ch4.informedsearch
Jarrar.lecture notes.aai.2011s.ch4.informedsearchJarrar.lecture notes.aai.2011s.ch4.informedsearch
Jarrar.lecture notes.aai.2011s.ch4.informedsearchPalGov
 
Chapter 4 review
Chapter 4 reviewChapter 4 review
Chapter 4 reviewgregcross22
 
Enumeration of 2-level polytopes
Enumeration of 2-level polytopesEnumeration of 2-level polytopes
Enumeration of 2-level polytopes
Vissarion Fisikopoulos
 
小波变换程序
小波变换程序小波变换程序
小波变换程序byron zhao
 
An efficient algorithm for the computation of Bernoulli numbers
 An efficient algorithm for the computation of Bernoulli numbers An efficient algorithm for the computation of Bernoulli numbers
An efficient algorithm for the computation of Bernoulli numbers
XequeMateShannon
 
Recurrence theorem
Recurrence theoremRecurrence theorem
Recurrence theorem
Rajendran
 
9.8.1 Parallel Resonance
9.8.1 Parallel Resonance9.8.1 Parallel Resonance
9.8.1 Parallel ResonanceTalia Carbis
 
Recursion tree method
Recursion tree methodRecursion tree method
Recursion tree method
Rajendran
 
Control system concepts by using matlab
Control system concepts by using matlabControl system concepts by using matlab
Control system concepts by using matlab
CharltonInao1
 
Laplace
LaplaceLaplace
lecture 4
lecture 4lecture 4
lecture 4sajinsc
 
Time complexity
Time complexityTime complexity
Time complexity
Katang Isip
 

What's hot (20)

Algorithum Analysis
Algorithum AnalysisAlgorithum Analysis
Algorithum Analysis
 
5
55
5
 
5th Semester Electronic and Communication Engineering (2013-June) Question Pa...
5th Semester Electronic and Communication Engineering (2013-June) Question Pa...5th Semester Electronic and Communication Engineering (2013-June) Question Pa...
5th Semester Electronic and Communication Engineering (2013-June) Question Pa...
 
5th Semester Electronic and Communication Engineering (June/July-2015) Questi...
5th Semester Electronic and Communication Engineering (June/July-2015) Questi...5th Semester Electronic and Communication Engineering (June/July-2015) Questi...
5th Semester Electronic and Communication Engineering (June/July-2015) Questi...
 
Jarrar.lecture notes.aai.2011s.ch4.informedsearch
Jarrar.lecture notes.aai.2011s.ch4.informedsearchJarrar.lecture notes.aai.2011s.ch4.informedsearch
Jarrar.lecture notes.aai.2011s.ch4.informedsearch
 
Datacompression1
Datacompression1Datacompression1
Datacompression1
 
Chapter 4 review
Chapter 4 reviewChapter 4 review
Chapter 4 review
 
Enumeration of 2-level polytopes
Enumeration of 2-level polytopesEnumeration of 2-level polytopes
Enumeration of 2-level polytopes
 
小波变换程序
小波变换程序小波变换程序
小波变换程序
 
An efficient algorithm for the computation of Bernoulli numbers
 An efficient algorithm for the computation of Bernoulli numbers An efficient algorithm for the computation of Bernoulli numbers
An efficient algorithm for the computation of Bernoulli numbers
 
9.8.2 Dangers
9.8.2 Dangers9.8.2 Dangers
9.8.2 Dangers
 
Recurrence theorem
Recurrence theoremRecurrence theorem
Recurrence theorem
 
9.8.1 Parallel Resonance
9.8.1 Parallel Resonance9.8.1 Parallel Resonance
9.8.1 Parallel Resonance
 
Recursion tree method
Recursion tree methodRecursion tree method
Recursion tree method
 
Ch04
Ch04Ch04
Ch04
 
Laplace table
Laplace tableLaplace table
Laplace table
 
Control system concepts by using matlab
Control system concepts by using matlabControl system concepts by using matlab
Control system concepts by using matlab
 
Laplace
LaplaceLaplace
Laplace
 
lecture 4
lecture 4lecture 4
lecture 4
 
Time complexity
Time complexityTime complexity
Time complexity
 

Viewers also liked

Gender detection using MATLAB
Gender detection using MATLABGender detection using MATLAB
Gender detection using MATLAB
Tanmay Bakshi
 
Ec2306 mini project report-matlab
Ec2306 mini project report-matlabEc2306 mini project report-matlab
Ec2306 mini project report-matlabunnimaya_k
 
Final project report
Final project reportFinal project report
Final project reportssuryawanshi
 
Mini Project- Audio Enhancement
Mini Project-  Audio EnhancementMini Project-  Audio Enhancement
Kaldi-voice: Your personal speech recognition server using open source code
Kaldi-voice: Your personal speech recognition server using open source codeKaldi-voice: Your personal speech recognition server using open source code
Kaldi-voice: Your personal speech recognition server using open source code
Xavier Anguera
 
FILTER BANKS
FILTER BANKSFILTER BANKS
FILTER BANKS
Sanjana Prasad
 
DSP MATLAB notes - Akshansh
DSP MATLAB notes - AkshanshDSP MATLAB notes - Akshansh
DSP MATLAB notes - Akshansh
Akshansh Chaudhary
 
Speech Recognition Technology
Speech Recognition TechnologySpeech Recognition Technology
Speech Recognition Technology
Seminar Links
 
Number plate recognition system using matlab.
Number plate recognition system using matlab.Number plate recognition system using matlab.
Number plate recognition system using matlab.
Namra Afzal
 
Speech Recognition System By Matlab
Speech Recognition System By MatlabSpeech Recognition System By Matlab
Speech Recognition System By Matlab
Ankit Gujrati
 
Designing a uniform filter bank using multirate concept
Designing a uniform filter bank using multirate conceptDesigning a uniform filter bank using multirate concept
Designing a uniform filter bank using multirate concept
রেদওয়ান অর্ণব
 
IEEE 2014 Final Year Projects | Digital Image Processing
IEEE 2014 Final Year Projects | Digital Image ProcessingIEEE 2014 Final Year Projects | Digital Image Processing
IEEE 2014 Final Year Projects | Digital Image Processing
E2MATRIX
 
Digitla Communication pulse shaping filter
Digitla Communication pulse shaping filterDigitla Communication pulse shaping filter
Digitla Communication pulse shaping filtermirfanjum
 
Multirate
MultirateMultirate
MultirateaiQUANT
 
Multrate dsp
Multrate dspMultrate dsp
Encryption & Decryption of Sound in image format on Matlab
Encryption & Decryption of Sound in image format on MatlabEncryption & Decryption of Sound in image format on Matlab
Encryption & Decryption of Sound in image format on Matlab
Muhammad Saif Ul Islam
 
Fourier series example
Fourier series exampleFourier series example
Fourier series exampleAbi finni
 
Design of Filter Circuits using MATLAB, Multisim, and Excel
Design of Filter Circuits using MATLAB, Multisim, and ExcelDesign of Filter Circuits using MATLAB, Multisim, and Excel
Design of Filter Circuits using MATLAB, Multisim, and Excel
David Sandy
 
Vehicle number plate recognition using matlab
Vehicle number plate recognition using matlabVehicle number plate recognition using matlab
Vehicle number plate recognition using matlab
Kongara Sudharshan
 

Viewers also liked (20)

Gender detection using MATLAB
Gender detection using MATLABGender detection using MATLAB
Gender detection using MATLAB
 
Ec2306 mini project report-matlab
Ec2306 mini project report-matlabEc2306 mini project report-matlab
Ec2306 mini project report-matlab
 
Final project report
Final project reportFinal project report
Final project report
 
Mini Project- Audio Enhancement
Mini Project-  Audio EnhancementMini Project-  Audio Enhancement
Mini Project- Audio Enhancement
 
Kaldi-voice: Your personal speech recognition server using open source code
Kaldi-voice: Your personal speech recognition server using open source codeKaldi-voice: Your personal speech recognition server using open source code
Kaldi-voice: Your personal speech recognition server using open source code
 
FILTER BANKS
FILTER BANKSFILTER BANKS
FILTER BANKS
 
DSP MATLAB notes - Akshansh
DSP MATLAB notes - AkshanshDSP MATLAB notes - Akshansh
DSP MATLAB notes - Akshansh
 
Speech Recognition Technology
Speech Recognition TechnologySpeech Recognition Technology
Speech Recognition Technology
 
Number plate recognition system using matlab.
Number plate recognition system using matlab.Number plate recognition system using matlab.
Number plate recognition system using matlab.
 
Speech Recognition System By Matlab
Speech Recognition System By MatlabSpeech Recognition System By Matlab
Speech Recognition System By Matlab
 
Designing a uniform filter bank using multirate concept
Designing a uniform filter bank using multirate conceptDesigning a uniform filter bank using multirate concept
Designing a uniform filter bank using multirate concept
 
IEEE 2014 Final Year Projects | Digital Image Processing
IEEE 2014 Final Year Projects | Digital Image ProcessingIEEE 2014 Final Year Projects | Digital Image Processing
IEEE 2014 Final Year Projects | Digital Image Processing
 
Digitla Communication pulse shaping filter
Digitla Communication pulse shaping filterDigitla Communication pulse shaping filter
Digitla Communication pulse shaping filter
 
Digfilt
DigfiltDigfilt
Digfilt
 
Multirate
MultirateMultirate
Multirate
 
Multrate dsp
Multrate dspMultrate dsp
Multrate dsp
 
Encryption & Decryption of Sound in image format on Matlab
Encryption & Decryption of Sound in image format on MatlabEncryption & Decryption of Sound in image format on Matlab
Encryption & Decryption of Sound in image format on Matlab
 
Fourier series example
Fourier series exampleFourier series example
Fourier series example
 
Design of Filter Circuits using MATLAB, Multisim, and Excel
Design of Filter Circuits using MATLAB, Multisim, and ExcelDesign of Filter Circuits using MATLAB, Multisim, and Excel
Design of Filter Circuits using MATLAB, Multisim, and Excel
 
Vehicle number plate recognition using matlab
Vehicle number plate recognition using matlabVehicle number plate recognition using matlab
Vehicle number plate recognition using matlab
 

Similar to Matlab dsp examples

The Moore-Spiegel Oscillator
The Moore-Spiegel OscillatorThe Moore-Spiegel Oscillator
The Moore-Spiegel Oscillator
Abhranil Das
 
DIGITAL SIGNAL PROCESSING BASED ON MATLAB
DIGITAL SIGNAL PROCESSING BASED ON MATLABDIGITAL SIGNAL PROCESSING BASED ON MATLAB
DIGITAL SIGNAL PROCESSING BASED ON MATLAB
Prashant Srivastav
 
Help with root locus homework1
Help with root locus homework1Help with root locus homework1
Help with root locus homework1Assignmentpedia
 
Matlab fair-record-model
Matlab fair-record-modelMatlab fair-record-model
Matlab fair-record-modelajaydev1111
 
Generating code from dags
Generating code from dagsGenerating code from dags
Generating code from dags
indhu mathi
 
matlab codes.pdf
matlab codes.pdfmatlab codes.pdf
matlab codes.pdf
EdysaulCondorhuancar
 
Volume and edge skeleton computation in high dimensions
Volume and edge skeleton computation in high dimensionsVolume and edge skeleton computation in high dimensions
Volume and edge skeleton computation in high dimensions
Vissarion Fisikopoulos
 
bask, bfsk, bpsk
bask, bfsk, bpskbask, bfsk, bpsk
bask, bfsk, bpsk
blzz2net
 
Ecg programa simulado
Ecg programa simuladoEcg programa simulado
Ecg programa simulado
Eduard Stiven Marin Montoya
 
Basic python programs
Basic python programsBasic python programs
Basic python programs
RaginiJain21
 
Verification with LoLA: 2 The LoLA Input Language
Verification with LoLA: 2 The LoLA Input LanguageVerification with LoLA: 2 The LoLA Input Language
Verification with LoLA: 2 The LoLA Input LanguageUniversität Rostock
 
Lesson 7: Vector-valued functions
Lesson 7: Vector-valued functionsLesson 7: Vector-valued functions
Lesson 7: Vector-valued functions
Matthew Leingang
 
Matlab 2
Matlab 2Matlab 2
Matlab 2asguna
 
ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม. 6 1
ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม. 6  1ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม. 6  1
ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม. 6 1Little Tukta Lita
 
Price of anarchy is independent of network topology
Price of anarchy is independent of network topologyPrice of anarchy is independent of network topology
Price of anarchy is independent of network topology
Aleksandr Yampolskiy
 
Stressen's matrix multiplication
Stressen's matrix multiplicationStressen's matrix multiplication
Stressen's matrix multiplicationKumar
 
Matlab assignment
Matlab assignmentMatlab assignment
Matlab assignment
Rutvik
 
Introduction to CFD FORTRAN code
Introduction to CFD FORTRAN codeIntroduction to CFD FORTRAN code
Introduction to CFD FORTRAN codeBehnam Bozorgmehr
 

Similar to Matlab dsp examples (20)

The Moore-Spiegel Oscillator
The Moore-Spiegel OscillatorThe Moore-Spiegel Oscillator
The Moore-Spiegel Oscillator
 
DIGITAL SIGNAL PROCESSING BASED ON MATLAB
DIGITAL SIGNAL PROCESSING BASED ON MATLABDIGITAL SIGNAL PROCESSING BASED ON MATLAB
DIGITAL SIGNAL PROCESSING BASED ON MATLAB
 
Help with root locus homework1
Help with root locus homework1Help with root locus homework1
Help with root locus homework1
 
Matlab fair-record-model
Matlab fair-record-modelMatlab fair-record-model
Matlab fair-record-model
 
Generating code from dags
Generating code from dagsGenerating code from dags
Generating code from dags
 
matlab codes.pdf
matlab codes.pdfmatlab codes.pdf
matlab codes.pdf
 
Md Nasfik
Md NasfikMd Nasfik
Md Nasfik
 
rubik_solve
rubik_solverubik_solve
rubik_solve
 
Volume and edge skeleton computation in high dimensions
Volume and edge skeleton computation in high dimensionsVolume and edge skeleton computation in high dimensions
Volume and edge skeleton computation in high dimensions
 
bask, bfsk, bpsk
bask, bfsk, bpskbask, bfsk, bpsk
bask, bfsk, bpsk
 
Ecg programa simulado
Ecg programa simuladoEcg programa simulado
Ecg programa simulado
 
Basic python programs
Basic python programsBasic python programs
Basic python programs
 
Verification with LoLA: 2 The LoLA Input Language
Verification with LoLA: 2 The LoLA Input LanguageVerification with LoLA: 2 The LoLA Input Language
Verification with LoLA: 2 The LoLA Input Language
 
Lesson 7: Vector-valued functions
Lesson 7: Vector-valued functionsLesson 7: Vector-valued functions
Lesson 7: Vector-valued functions
 
Matlab 2
Matlab 2Matlab 2
Matlab 2
 
ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม. 6 1
ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม. 6  1ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม. 6  1
ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม. 6 1
 
Price of anarchy is independent of network topology
Price of anarchy is independent of network topologyPrice of anarchy is independent of network topology
Price of anarchy is independent of network topology
 
Stressen's matrix multiplication
Stressen's matrix multiplicationStressen's matrix multiplication
Stressen's matrix multiplication
 
Matlab assignment
Matlab assignmentMatlab assignment
Matlab assignment
 
Introduction to CFD FORTRAN code
Introduction to CFD FORTRAN codeIntroduction to CFD FORTRAN code
Introduction to CFD FORTRAN code
 

More from umarjamil10000

Galvanometer,wheatstone bridge,ohm law,
Galvanometer,wheatstone bridge,ohm  law,Galvanometer,wheatstone bridge,ohm  law,
Galvanometer,wheatstone bridge,ohm law,
umarjamil10000
 
Mechatronics, Embedded System,
Mechatronics, Embedded System,Mechatronics, Embedded System,
Mechatronics, Embedded System,
umarjamil10000
 
Electric Field
Electric FieldElectric Field
Electric Field
umarjamil10000
 
Image denoising
Image denoising Image denoising
Image denoising
umarjamil10000
 
Coding verilog
Coding verilogCoding verilog
Coding verilog
umarjamil10000
 
noise removal in matlab
noise removal in matlabnoise removal in matlab
noise removal in matlab
umarjamil10000
 
Pm project
Pm projectPm project
Pm project
umarjamil10000
 
Mechatronics systems
Mechatronics systemsMechatronics systems
Mechatronics systems
umarjamil10000
 

More from umarjamil10000 (8)

Galvanometer,wheatstone bridge,ohm law,
Galvanometer,wheatstone bridge,ohm  law,Galvanometer,wheatstone bridge,ohm  law,
Galvanometer,wheatstone bridge,ohm law,
 
Mechatronics, Embedded System,
Mechatronics, Embedded System,Mechatronics, Embedded System,
Mechatronics, Embedded System,
 
Electric Field
Electric FieldElectric Field
Electric Field
 
Image denoising
Image denoising Image denoising
Image denoising
 
Coding verilog
Coding verilogCoding verilog
Coding verilog
 
noise removal in matlab
noise removal in matlabnoise removal in matlab
noise removal in matlab
 
Pm project
Pm projectPm project
Pm project
 
Mechatronics systems
Mechatronics systemsMechatronics systems
Mechatronics systems
 

Recently uploaded

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
bennyroshan06
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
Jheel Barad
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
BhavyaRajput3
 
Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chips
GeoBlogs
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
PedroFerreira53928
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
Fundacja Rozwoju Społeczeństwa Przedsiębiorczego
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
Nguyen Thanh Tu Collection
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
Celine George
 
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
AzmatAli747758
 

Recently uploaded (20)

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
 
Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chips
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
 
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
 

Matlab dsp examples

  • 1. MATLAB DSP Programs Raja Rajasakeran Venkat Peddigari Pete Bernardin
  • 2. Bandpass Filter close all; clear all; r1 = 0.9; r2 = 0.88; r3=0.9; theta1 = pi/5; theta2 = 3*pi/10; theta3=4*pi/10; p1 = r1*cos(theta1) + i*r1*sin(theta1); p2 = r1*cos(theta2) + i*r2*sin(theta2); p3 = r3*cos(theta3) + i*r3*sin(theta3); p2 = r2*cos(theta2) + i*r2*sin(theta2); !aroots = [p1,conj(p1),p2,conj(p2), p3, conj(p3)]; aroots = [p2,conj(p2), p3, conj(p3)]; a = poly(aroots); b = [1 zeros(1,18) -1]; b1 = [1]; [h,w] = freqz(b1,a); freqzplot(h,w, 'mag'); figure; freqzplot(h,w,'squared'); ( )( ) ( )( )[ ] ( ) ( ) ( ) ( )[ ]2121 4.0 21 3 3.0 21 2 1111 )4.0cos(219.0)3.0cos(219.0/1 cos219.0cos219.0/1 119.0119.0/1)( 32 3322 −−−− = −− = −− −−−+−−−+ +−+−=       +−+−= −−−−= zzzz zzzz zezezezezH jjjj ππ ωω πωπω ωωωω
  • 3. Kaiser Bessel Window clear all; close all; N=61; w31 = window(@kaiser,N,1); w33 = window(@kaiser,N,3); w35 = window(@kaiser,N,5); w37 = window(@kaiser,N,7); plot(1:N,[w31, w33, w35, w37]); axis([1 N 0 1]); legend('beta=1','beta = 3', 'beta=5', 'beta=7'); figure; a=[1]; [fw31,f] = freqz(w31,a); [fw33,f] = freqz(w33,a); [fw35,f] = freqz(w35,a); [fw37,f] = freqz(w37,a); freqzplot([fw31,fw33,fw35,fw37],f, 'mag'); legend('beta=1','beta = 3', 'beta=5', 'beta=7');
  • 4. Time Domain Windows clear all; close all; N=61; w = window(@blackmanharris,N); w1 = window(@hamming,N); w2 = window(@gausswin,N,2.5); w3 = window(@kaiser,N,5); w4 = window(@tukeywin,N,0.5); plot(1:N,[w1,w3,w4]); axis([1 N 0 1]); legend('Hamming','Kaiser', 'Tukey'); figure; a=[1]; [fw,f] = freqz(w,a); [fw1,f] = freqz(w1,a); [fw2,f] = freqz(w2,a); [fw3,f] = freqz(w3,a); [fw4,f] = freqz(w4,a); freqzplot([fw1,fw3,fw4],f, 'mag'); legend('Hamming','Kaiser', 'Tukey');
  • 5. DFT of Square Waves, 3 Duties close all; clear all; x = ones(1,16); y = fft(x,16); my = abs(y)/16; ay = angle(y); stem(my); figure; y1 = fft (x,32)/16; my1 = abs(y1); stem(my1); y2= fft (x,128); figure; stem (abs(y2)); 100% Duty 50% Duty 12.5% Duty
  • 6. Notch Filters clear all; close all; a = [1 -1.2726 0.81]; b = [1 -1.414 1]; [H, W] = freqz(b,a); figure; freqzplot(H,W,'linear'); title ('Pole-zero Notch Filter - Mag'); figure; freqzplot(H,W); title ('Pole-zero Notch Filter - dB'); a1 = [1]; b1 = [1 -1.414 1]; [H1, W] = freqz(b1,a1); figure; freqzplot(H1,W,'linear'); title ('All zero Notch Filter - Mag'); figure; freqzplot(H1,W); title ('All zero Notch Filter - dB'); 1 2 3 4
  • 7. Resonators clear all; close all; r = 0.99; theta = pi/4; a = [1 -2*r*theta r^2]; b = 1; [H, W] = freqz(b,a); figure; freqzplot(H,W,'linear'); title ('Resonator r=0.99, theta = pi/4 - Mag'); figure; freqzplot(H,W); title (' Resonator r=0.99, theta = pi/4- dB'); r = 0.95; theta = pi/4; a = [1 -2*r*theta r^2]; b = 1; [H, W] = freqz(b,a); figure; freqzplot(H,W,'linear'); title ('Resonator r=0.95, theta = pi/4 - Mag'); figure; freqzplot(H,W); title (' Resonator r=0.95, theta = pi/4- dB'); r = 0.99; theta = pi/4; a = [1 -2*r*theta r^2]; b = [1 0 -1] [H, W] = freqz(b,a); figure; freqzplot(H,W,'linear'); title ('Pole-zero Resonator r=0.99, theta = pi/4 - Mag'); figure; freqzplot(H,W); title ('Pole-zero Resonator r=0.99, theta = pi/4- dB'); r = 0.9; theta = pi/4; a = [1 -2*r*theta r^2]; b = 1; [H, W] = freqz(b,a); figure; freqzplot(H,W,'linear'); title ('Resonator r=0.9, theta = pi/4 - Mag'); figure; freqzplot(H,W); title (' Resonator r=0.9, theta = pi/4- dB'); r = 1.0; theta = pi/4; a = [1 -2*r*theta r^2]; b = 1; [H, W] = freqz(b,a); figure; freqzplot(H,W,'linear'); title ('Oscillator, theta = pi/4 - Mag'); figure; freqzplot(H,W); title ('Oscillator, theta = pi/4- dB'); 1
  • 9. Comb Filters clear all; close all; a = [1 -1]; b = [1 0 0 0 0 0 0 0 0 0 0 -1]; b = b/11; [H, W] = freqz(b,a); figure; freqzplot(H,W,'linear'); title ('Comb Filter M=10 - Mag'); figure; freqzplot(H,W); title ('Comb Filter M=10 - dB'); bz = zeros (1,54); a1 = [1 0 0 0 0 -1]; b1 = [1 [bz] -1]; [H, W] = freqz(b1,a1); figure; freqzplot(H,W,'linear'); title ('LM Comb Filter L = 5 M=10 - Mag'); figure; freqzplot(H,W); title ('LM Comb Filter L = 5 M=10 - dB'); 1 2 3 4
  • 10. Welch Periodogram PSD close all; clear all; t = 0:.001:4.096; x = sin(2*pi*50*t) + sin(2*pi*120*t); stdev = 2; y = x + stdev*randn(size(t)); figure; plot(y(1:50)) title('Noisy time domain signal') FS = 1000.; % Sampling Rate % 1 section NFFT = 4096; Noverlap = 0 figure; pwelch(y, 4096, Noverlap, NFFT, FS) % 16 overlapping sections NFFT = 512; Noverlap = 256 figure; pwelch(y, 512, Noverlap, NFFT, FS) % 32 overlapping sections NFFT = 256; Noverlap = 128 figure; pwelch(y, 256, Noverlap, NFFT, FS) ¼ Hz Res 2 Hz Res 4 Hz Res Time 1 2 43
  • 11. Discrete Fourier Transform (DFT) Forward Transform: for k=0,1,2,…,N-1 Inverse Transform: for n=0,1,2,…,N-1 ----------------------------------------------------------------------------------------------------------- N=8; % MATLAB “DISCRETE FOURIER TRANSFORM” PROGRAM w0 = 2*pi/N; K0 =3; w=w0*K0*(0:N-1); Data = complex(cos(w),sin(w)); % Data = ej2πnKo/N for k =1:N accum=complex(0,0); for n=1:N A = w0*(n-1)*(k-1); Twiddle=complex(cos(A),-sin(A)); %Twiddle = e-j2πnk/N accum = accum+Data(n)*Twiddle; % X(k)= Σej2πnKo/N e-j2πnk/N end % "n" is Time index MAGXk=abs(accum) % Output the Magnitude of the DFT =N @ k=K0 end % "k" is the Frequency index