SlideShare a Scribd company logo
1 of 3
Download to read offline
DISCRETE – TIME SIGNALS PLOTTING ON MATLAB
EXAMPLE
Solution by: MartinWachiye Wafula
MultimediaUniversity of Kenya
wachiyem@gmail.com
Problem:
Using MATLAB, producethe plot for (a), (d), (g) and (h)
Solution:
The code on MATLAB is as shownbelow:
%DISCRETE-TIME SIGNALS
%Author: Martin Wachiye Wafula
% Multimedia University of Kenya
%Date: 15th February, 2017
n = -6:6;
%The original signal x[n]
xn =((n+1)==0)+ (n==0)+ ((n-1)==0)+ ((n-2)==0)+ ...
0.5*(((n-3)==0)+ ((n-4)==0));
subplot(3,2,1)
stem(n,xn,'filled'), xlabel('n'), ylabel('x[n]')
title('plot of x[n]'), grid
%x[n] could also be plotted using the code below
% xn1 = ((n+1)==0)+(n>=0)-((n-3)>=0)+0.5*(((n-3)>=0)-((n-5)>=0));
%stem(n,xn1,'filled')
%(a) signal x[n-2]
xn_a = (((n-2)+1)==0)+ ((n-2)==0) + (((n-2)-1)==0) + ...
(((n-2)-2)==0) + 0.5*((((n-2)-3)==0) + (((n-2)-4)==0) );
subplot(3,2,2)
stem(n,xn_a,'filled'), xlabel('n'), ylabel('x[n-2]')
title('plot(a) x(n-2)'),grid
%signal (d): x[n]u[2-n]
xn_d = xn .*((2-n)>=0);
subplot(3,2,3)
stem(n,xn_d,'filled'), xlabel('n'), ylabel('x[n]u[2-n]')
title('plot(d) x[n]u[2-n]'),grid
% to obtain odd and even part of the signal x[n]
xN = fliplr(xn); %reversed version of x[n] i.e x[-n]
xe = (xn + xN)/2; %computing the even part
xo = (xn - xN)/2; %computing the odd part
ver = xn - (xe + xo) % to verify our decomposition
subplot(3,2,4)
stem(n,xe,'filled'), xlabel('n'), ylabel('xe[n]'),axis([-6 6 -1 1.5])
title('(g) Even Part'), grid
subplot(3,2,5)
stem(n,xo,'filled'), xlabel('n'), ylabel('xo[n]'),axis([-6 6 -1 1.5])
title('(h) Odd Part'), grid
The plots obtainedfrom running the code are as depictedby the screenshot
below:
Discrete time signals on MATLAB

More Related Content

What's hot

What's hot (20)

Matched filter
Matched filterMatched filter
Matched filter
 
DIT-Radix-2-FFT in SPED
DIT-Radix-2-FFT in SPEDDIT-Radix-2-FFT in SPED
DIT-Radix-2-FFT in SPED
 
08 multiplexing
08 multiplexing08 multiplexing
08 multiplexing
 
Z transform ROC eng.Math
Z transform ROC eng.MathZ transform ROC eng.Math
Z transform ROC eng.Math
 
inverse z-transform ppt
inverse z-transform pptinverse z-transform ppt
inverse z-transform ppt
 
DIGITAL COMMUNICATION: ENCODING AND DECODING OF CYCLIC CODE
DIGITAL COMMUNICATION: ENCODING AND DECODING OF CYCLIC CODE DIGITAL COMMUNICATION: ENCODING AND DECODING OF CYCLIC CODE
DIGITAL COMMUNICATION: ENCODING AND DECODING OF CYCLIC CODE
 
Source coding
Source coding Source coding
Source coding
 
THE CMOS VLSI DESIGN
THE CMOS VLSI DESIGNTHE CMOS VLSI DESIGN
THE CMOS VLSI DESIGN
 
Digital control systems (dcs) lecture 18-19-20
Digital control systems (dcs) lecture 18-19-20Digital control systems (dcs) lecture 18-19-20
Digital control systems (dcs) lecture 18-19-20
 
Dsp lab manual
Dsp lab manualDsp lab manual
Dsp lab manual
 
Convolutional codes
Convolutional codesConvolutional codes
Convolutional codes
 
Z Transform
Z TransformZ Transform
Z Transform
 
Reed Solomon encoder and decoder \ ريد سلمون
Reed Solomon encoder and decoder \ ريد سلمونReed Solomon encoder and decoder \ ريد سلمون
Reed Solomon encoder and decoder \ ريد سلمون
 
Z transform
Z transformZ transform
Z transform
 
Dft
DftDft
Dft
 
linear codes and cyclic codes
linear codes and cyclic codeslinear codes and cyclic codes
linear codes and cyclic codes
 
Reed solomon Encoder and Decoder
Reed solomon Encoder and DecoderReed solomon Encoder and Decoder
Reed solomon Encoder and Decoder
 
Decimation in time and frequency
Decimation in time and frequencyDecimation in time and frequency
Decimation in time and frequency
 
quantization
quantizationquantization
quantization
 
Computing DFT using Matrix method
Computing DFT using Matrix methodComputing DFT using Matrix method
Computing DFT using Matrix method
 

Viewers also liked

discrete time signals and systems
 discrete time signals and systems discrete time signals and systems
discrete time signals and systems
Zlatan Ahmadovic
 
журавка яна
журавка янажуравка яна
журавка яна
utyyflbq
 

Viewers also liked (11)

DIGITAL SIGNAL PROCESSING: Sampling and Reconstruction on MATLAB
DIGITAL SIGNAL PROCESSING: Sampling and Reconstruction on MATLABDIGITAL SIGNAL PROCESSING: Sampling and Reconstruction on MATLAB
DIGITAL SIGNAL PROCESSING: Sampling and Reconstruction on MATLAB
 
Report ada
Report adaReport ada
Report ada
 
Outside the frame: Information and experience design in 360°
Outside the frame: Information and experience design in 360°Outside the frame: Information and experience design in 360°
Outside the frame: Information and experience design in 360°
 
The beauty of infomation
The beauty of infomationThe beauty of infomation
The beauty of infomation
 
Kdtm trinh bayduan-v1.1
Kdtm trinh bayduan-v1.1Kdtm trinh bayduan-v1.1
Kdtm trinh bayduan-v1.1
 
4 pillars to the science of marketing
4 pillars to the science of marketing4 pillars to the science of marketing
4 pillars to the science of marketing
 
discrete time signals and systems
 discrete time signals and systems discrete time signals and systems
discrete time signals and systems
 
журавка яна
журавка янажуравка яна
журавка яна
 
Printed av aid
Printed av aidPrinted av aid
Printed av aid
 
Manejo de los síntomas vasomotores y del síndrome genitourinario en pacientes...
Manejo de los síntomas vasomotores y del síndrome genitourinario en pacientes...Manejo de los síntomas vasomotores y del síndrome genitourinario en pacientes...
Manejo de los síntomas vasomotores y del síndrome genitourinario en pacientes...
 
Mi ppt inicial
Mi ppt inicialMi ppt inicial
Mi ppt inicial
 

Similar to Discrete time signals on MATLAB

Natural and Clamped Cubic Splines
Natural and Clamped Cubic SplinesNatural and Clamped Cubic Splines
Natural and Clamped Cubic Splines
Mark Brandao
 
Seminar PSU 09.04.2013 - 10.04.2013 MiFIT, Arbuzov Vyacheslav
Seminar PSU 09.04.2013 - 10.04.2013 MiFIT, Arbuzov VyacheslavSeminar PSU 09.04.2013 - 10.04.2013 MiFIT, Arbuzov Vyacheslav
Seminar PSU 09.04.2013 - 10.04.2013 MiFIT, Arbuzov Vyacheslav
Vyacheslav Arbuzov
 

Similar to Discrete time signals on MATLAB (20)

Mat lab
Mat labMat lab
Mat lab
 
Matlab programs
Matlab programsMatlab programs
Matlab programs
 
Mathematica for Physicits
Mathematica for PhysicitsMathematica for Physicits
Mathematica for Physicits
 
Digital signal Processing all matlab code with Lab report
Digital signal Processing all matlab code with Lab report Digital signal Processing all matlab code with Lab report
Digital signal Processing all matlab code with Lab report
 
Matlab Assignment Help
Matlab Assignment HelpMatlab Assignment Help
Matlab Assignment Help
 
Matlab1
Matlab1Matlab1
Matlab1
 
[신경망기초] 합성곱신경망
[신경망기초] 합성곱신경망[신경망기초] 합성곱신경망
[신경망기초] 합성곱신경망
 
Natural and Clamped Cubic Splines
Natural and Clamped Cubic SplinesNatural and Clamped Cubic Splines
Natural and Clamped Cubic Splines
 
Rcommands-for those who interested in R.
Rcommands-for those who interested in R.Rcommands-for those who interested in R.
Rcommands-for those who interested in R.
 
Signals and Systems Homework Help.pptx
Signals and Systems Homework Help.pptxSignals and Systems Homework Help.pptx
Signals and Systems Homework Help.pptx
 
Matlab algebra
Matlab algebraMatlab algebra
Matlab algebra
 
Introduction to Machine Learning
Introduction to Machine LearningIntroduction to Machine Learning
Introduction to Machine Learning
 
Neural networks with python
Neural networks with pythonNeural networks with python
Neural networks with python
 
MATLAB for Technical Computing
MATLAB for Technical ComputingMATLAB for Technical Computing
MATLAB for Technical Computing
 
Seminar PSU 09.04.2013 - 10.04.2013 MiFIT, Arbuzov Vyacheslav
Seminar PSU 09.04.2013 - 10.04.2013 MiFIT, Arbuzov VyacheslavSeminar PSU 09.04.2013 - 10.04.2013 MiFIT, Arbuzov Vyacheslav
Seminar PSU 09.04.2013 - 10.04.2013 MiFIT, Arbuzov Vyacheslav
 
DSP_DiscSignals_LinearS_150417.pptx
DSP_DiscSignals_LinearS_150417.pptxDSP_DiscSignals_LinearS_150417.pptx
DSP_DiscSignals_LinearS_150417.pptx
 
Introduction to MATLAB
Introduction to MATLABIntroduction to MATLAB
Introduction to MATLAB
 
Lent Matlab H Ss
Lent Matlab H SsLent Matlab H Ss
Lent Matlab H Ss
 
Computer algebra-system-maple
Computer algebra-system-mapleComputer algebra-system-maple
Computer algebra-system-maple
 
Applied machine learning for search engine relevance 3
Applied machine learning for search engine relevance 3Applied machine learning for search engine relevance 3
Applied machine learning for search engine relevance 3
 

More from Martin Wachiye Wafula

More from Martin Wachiye Wafula (10)

Introduction to information theory
Introduction to information theoryIntroduction to information theory
Introduction to information theory
 
Intelligent reflecting surfaces (IRS)
Intelligent reflecting surfaces  (IRS)Intelligent reflecting surfaces  (IRS)
Intelligent reflecting surfaces (IRS)
 
ELECTRONIC MANAGEMENT SYSTEM BASED ON RFID AND USSD
ELECTRONIC MANAGEMENT SYSTEM BASED ON RFID AND USSDELECTRONIC MANAGEMENT SYSTEM BASED ON RFID AND USSD
ELECTRONIC MANAGEMENT SYSTEM BASED ON RFID AND USSD
 
Disruptive technologies and market place
Disruptive technologies and market placeDisruptive technologies and market place
Disruptive technologies and market place
 
5G: LET'S DEMYSTIFY IT, 5G Technology Update
5G: LET'S DEMYSTIFY IT, 5G Technology Update5G: LET'S DEMYSTIFY IT, 5G Technology Update
5G: LET'S DEMYSTIFY IT, 5G Technology Update
 
Analog filters matlab_examples
Analog filters matlab_examplesAnalog filters matlab_examples
Analog filters matlab_examples
 
Matlab task1
Matlab task1Matlab task1
Matlab task1
 
Matlab problems
Matlab problemsMatlab problems
Matlab problems
 
Discrete time signals on MATLAB
Discrete time signals on MATLABDiscrete time signals on MATLAB
Discrete time signals on MATLAB
 
Unity in diversity
Unity in diversityUnity in diversity
Unity in diversity
 

Recently uploaded

VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
dharasingh5698
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
ankushspencer015
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
dollysharma2066
 
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
ssuser89054b
 

Recently uploaded (20)

Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 
chapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringchapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineering
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
 
Call for Papers - International Journal of Intelligent Systems and Applicatio...
Call for Papers - International Journal of Intelligent Systems and Applicatio...Call for Papers - International Journal of Intelligent Systems and Applicatio...
Call for Papers - International Journal of Intelligent Systems and Applicatio...
 
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
 
Unit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfUnit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdf
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdf
 
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank  Design by Working Stress - IS Method.pdfIntze Overhead Water Tank  Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
 
Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
 
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 

Discrete time signals on MATLAB

  • 1. DISCRETE – TIME SIGNALS PLOTTING ON MATLAB EXAMPLE Solution by: MartinWachiye Wafula MultimediaUniversity of Kenya wachiyem@gmail.com Problem: Using MATLAB, producethe plot for (a), (d), (g) and (h) Solution: The code on MATLAB is as shownbelow: %DISCRETE-TIME SIGNALS %Author: Martin Wachiye Wafula % Multimedia University of Kenya %Date: 15th February, 2017 n = -6:6; %The original signal x[n] xn =((n+1)==0)+ (n==0)+ ((n-1)==0)+ ((n-2)==0)+ ... 0.5*(((n-3)==0)+ ((n-4)==0)); subplot(3,2,1) stem(n,xn,'filled'), xlabel('n'), ylabel('x[n]') title('plot of x[n]'), grid %x[n] could also be plotted using the code below % xn1 = ((n+1)==0)+(n>=0)-((n-3)>=0)+0.5*(((n-3)>=0)-((n-5)>=0)); %stem(n,xn1,'filled') %(a) signal x[n-2] xn_a = (((n-2)+1)==0)+ ((n-2)==0) + (((n-2)-1)==0) + ... (((n-2)-2)==0) + 0.5*((((n-2)-3)==0) + (((n-2)-4)==0) );
  • 2. subplot(3,2,2) stem(n,xn_a,'filled'), xlabel('n'), ylabel('x[n-2]') title('plot(a) x(n-2)'),grid %signal (d): x[n]u[2-n] xn_d = xn .*((2-n)>=0); subplot(3,2,3) stem(n,xn_d,'filled'), xlabel('n'), ylabel('x[n]u[2-n]') title('plot(d) x[n]u[2-n]'),grid % to obtain odd and even part of the signal x[n] xN = fliplr(xn); %reversed version of x[n] i.e x[-n] xe = (xn + xN)/2; %computing the even part xo = (xn - xN)/2; %computing the odd part ver = xn - (xe + xo) % to verify our decomposition subplot(3,2,4) stem(n,xe,'filled'), xlabel('n'), ylabel('xe[n]'),axis([-6 6 -1 1.5]) title('(g) Even Part'), grid subplot(3,2,5) stem(n,xo,'filled'), xlabel('n'), ylabel('xo[n]'),axis([-6 6 -1 1.5]) title('(h) Odd Part'), grid The plots obtainedfrom running the code are as depictedby the screenshot below: