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

Synchronous counters
Synchronous countersSynchronous counters
Synchronous counters
Lee Diaz
 

What's hot (20)

ROOT OF NON-LINEAR EQUATIONS
ROOT OF NON-LINEAR EQUATIONSROOT OF NON-LINEAR EQUATIONS
ROOT OF NON-LINEAR EQUATIONS
 
Programmable logic array
Programmable logic arrayProgrammable logic array
Programmable logic array
 
Unit I discrete mathematics lecture notes
Unit I  discrete mathematics lecture notesUnit I  discrete mathematics lecture notes
Unit I discrete mathematics lecture notes
 
Matlab solved problems
Matlab solved problemsMatlab solved problems
Matlab solved problems
 
K map
K mapK map
K map
 
Eigen valus n vectors
Eigen valus n vectors Eigen valus n vectors
Eigen valus n vectors
 
Mathematical Modeling for Practical Problems
Mathematical Modeling for Practical ProblemsMathematical Modeling for Practical Problems
Mathematical Modeling for Practical Problems
 
Block diagrams and signal flow graphs
Block diagrams and signal flow graphsBlock diagrams and signal flow graphs
Block diagrams and signal flow graphs
 
Array multiplier
Array multiplierArray multiplier
Array multiplier
 
scilab
scilabscilab
scilab
 
Gram-Schmidt process
Gram-Schmidt processGram-Schmidt process
Gram-Schmidt process
 
Fuzzy logic
Fuzzy logicFuzzy logic
Fuzzy logic
 
GAUSS ELIMINATION METHOD
 GAUSS ELIMINATION METHOD GAUSS ELIMINATION METHOD
GAUSS ELIMINATION METHOD
 
MODELLING, ANALYSIS AND SIMULATION OF DYNAMIC SYSTEMS USING CONTROL TECHNIQUE...
MODELLING, ANALYSIS AND SIMULATION OF DYNAMIC SYSTEMS USING CONTROL TECHNIQUE...MODELLING, ANALYSIS AND SIMULATION OF DYNAMIC SYSTEMS USING CONTROL TECHNIQUE...
MODELLING, ANALYSIS AND SIMULATION OF DYNAMIC SYSTEMS USING CONTROL TECHNIQUE...
 
Photoelectric Effect
Photoelectric EffectPhotoelectric Effect
Photoelectric Effect
 
Synchronous counters
Synchronous countersSynchronous counters
Synchronous counters
 
Fuzzy logic
Fuzzy logicFuzzy logic
Fuzzy logic
 
Tensor analysis
Tensor analysisTensor analysis
Tensor analysis
 
Simulation and Comparison of P, PI, PID Controllers on MATLAB/ Simulink
Simulation and Comparison of P, PI, PID Controllers on MATLAB/ SimulinkSimulation and Comparison of P, PI, PID Controllers on MATLAB/ Simulink
Simulation and Comparison of P, PI, PID Controllers on MATLAB/ Simulink
 
presentation on Euler and Modified Euler method ,and Fitting of curve
presentation on Euler and Modified Euler method ,and Fitting of curve presentation on Euler and Modified Euler method ,and Fitting of curve
presentation on Euler and Modified Euler method ,and Fitting of curve
 

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
 
Dsp lab manual
Dsp lab manualDsp lab manual
Dsp lab manual
 
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
 

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
 
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night StandCall Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
amitlee9823
 
notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.ppt
MsecMca
 

Recently uploaded (20)

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
 
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
 
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night StandCall Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
 
Intro To Electric Vehicles PDF Notes.pdf
Intro To Electric Vehicles PDF Notes.pdfIntro To Electric Vehicles PDF Notes.pdf
Intro To Electric Vehicles PDF Notes.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
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
 
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
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdf
 
notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.ppt
 
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
 
Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.ppt
 
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...
 
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leap
 
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
 

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: