SlideShare una empresa de Scribd logo
1 de 23
Descargar para leer sin conexión
Lab No.04

MATLAB graphics

Designed by : Dawar Awan
dawar@cecos.edu.pk
CECOS College of Engineering and IT

March – July 2012
Discrete signals
 Plot the discrete signal x = [1 2 3 4] in MATLAB
4

3
2

1

-1

0

1

2

 using stem(x) plots the signal starting from index number 1
CECOS College of Engineering and IT

March – July 2012
Practice
 Plot the following discrete time sequences

x[n]=[1 1 1 1 2 1 1 1 1]

x[n]=[5 4 3 2 1 0 1 2 3 4 5]

CECOS College of Engineering and IT

March – July 2012
Continuous plot
 >> plot(n,x)
 Shows a continuous plot of x
 Actually the discrete points are only connected with
straight lines.

CECOS College of Engineering and IT

March – July 2012
Labeling the plot
 Example:

CECOS College of Engineering and IT

March – July 2012
Labeling the plot

CECOS College of Engineering and IT

March – July 2012
Multiple plots
 Using single “plot” instruction
 Example:

x = 0:0.01:5;
y1=sin(x);
y2=sin(2*x);
y3=sin(4*x);
plot(x,y1,x,y2,x,y3)

CECOS College of Engineering and IT

March – July 2012
Multiple plots

CECOS College of Engineering and IT

March – July 2012
Multiple plots
 Using multiple “plot” instructions
 Example:

x = 0:0.01:5;
y1=sin(x);
y2=sin(2*x);
y3=sin(4*x);
plot(x,y1);
hold on;
plot(x,y2);
plot(x,y3);

CECOS College of Engineering and IT

March – July 2012
Multiple plots

CECOS College of Engineering and IT

March – July 2012
Changing default plot settings
 Example:
x = 0:0.1:5;
y1=sin(x);
y2=sin(2*x);
y3=sin(4*x);

plot(x,y1,’+’,x,y2,':',x,y3,‘--');

CECOS College of Engineering and IT

March – July 2012
Changing default plot settings

CECOS College of Engineering and IT

March – July 2012
Changing default plot settings
 line types and mark types
Linetypes :

solid (-), dashed (--), dotted (:), dashdot (-.)

Marktypes :

point (.), plus (+), star (*), circle (o), x-mark (x)

Check the help of “plot” for more effects.
CECOS College of Engineering and IT

March – July 2012
Axis command
 Used to manually zoom axis
 axis([xmin xmax ymin ymax])
 Example:

CECOS College of Engineering and IT

March – July 2012
Axis command
 Without axis command

CECOS College of Engineering and IT

March – July 2012
Axis command
 With axis command

CECOS College of Engineering and IT

March – July 2012
SUBPLOT
 Example:
x = 0:1:10;
y = x.^2;
z = 10*x;
subplot (1,2,1)

plot(x,y)
subplot (1,2,2)
plot(x,z)
subplot(m,n,p) : makes m rows and n columns of figures in figure window
and p shows the location of the current plot i.e the plot instruction just below
the subplot
CECOS College of Engineering and IT

March – July 2012
SUBPLOT

CECOS College of Engineering and IT

March – July 2012
Generating a sine wave
 Example: creating a 5Hz sine wave, sampled at 8000Hz.
f=5;
fs=8000;
t=[0:1/fs:1];
y=sin(2*pi*f*t);
plot(t,y);

CECOS College of Engineering and IT

March – July 2012
Generating a sine wave
 Observe 5 cycles per second.

CECOS College of Engineering and IT

March – July 2012
Generating a sine wave
 Example: Creating a 1000Hz sine wave, sampled at
8000Hz, and routing it to computer’s soundcard.
f=1000;
fs=8000;
t=[0:1/fs:3];
y=sin(2*pi*f*t);
sound(y,fs);

The sound will be heard for 3 seconds, as dictated by the code
CECOS College of Engineering and IT

March – July 2012
Task
1. Plot the two curves y1 = x2 and y2 = 2x on the same graph using

different plot styles. Label the plot properly
2. Write a MATLAB program that adds the following two signals,
Plot the original signals as well as their sum.
x1[n] = [2 2 2 2 2]
x2[n] = [2 2 2 2 0 0]
3. Scale the amplitude of the following signal by a factor of 2 and
½ and show the scaled signals along with the original.

x(t) = sin(t) + 1/3sin(3t)
CECOS College of Engineering and IT

,

t=0:0.01:10
March – July 2012
Tasks
4. Demonstrate the use of the function ”plot3” to plot a straight
3D line

CECOS College of Engineering and IT

March – July 2012

Más contenido relacionado

La actualidad más candente

Variables in matlab
Variables in matlabVariables in matlab
Variables in matlab
TUOS-Sam
 
Permutation graphsandapplications
Permutation graphsandapplicationsPermutation graphsandapplications
Permutation graphsandapplications
Joe Krall
 
Math making connections
Math   making connectionsMath   making connections
Math making connections
courtney.smith
 
ARCHAEOLOGICAL LAND USE CHARACTERIZATION USING MULTISPECTRAL REMOTE SENSING DATA
ARCHAEOLOGICAL LAND USE CHARACTERIZATION USING MULTISPECTRAL REMOTE SENSING DATAARCHAEOLOGICAL LAND USE CHARACTERIZATION USING MULTISPECTRAL REMOTE SENSING DATA
ARCHAEOLOGICAL LAND USE CHARACTERIZATION USING MULTISPECTRAL REMOTE SENSING DATA
grssieee
 
Lecture 14 data structures and algorithms
Lecture 14 data structures and algorithmsLecture 14 data structures and algorithms
Lecture 14 data structures and algorithms
Aakash deep Singhal
 

La actualidad más candente (20)

Variables in matlab
Variables in matlabVariables in matlab
Variables in matlab
 
R programmingmilano
R programmingmilanoR programmingmilano
R programmingmilano
 
Permutation graphsandapplications
Permutation graphsandapplicationsPermutation graphsandapplications
Permutation graphsandapplications
 
Math making connections
Math   making connectionsMath   making connections
Math making connections
 
ARCHAEOLOGICAL LAND USE CHARACTERIZATION USING MULTISPECTRAL REMOTE SENSING DATA
ARCHAEOLOGICAL LAND USE CHARACTERIZATION USING MULTISPECTRAL REMOTE SENSING DATAARCHAEOLOGICAL LAND USE CHARACTERIZATION USING MULTISPECTRAL REMOTE SENSING DATA
ARCHAEOLOGICAL LAND USE CHARACTERIZATION USING MULTISPECTRAL REMOTE SENSING DATA
 
COLLEGE OF COMPUTING AND INFORMATICS Assignment – 4
COLLEGE OF COMPUTING AND INFORMATICS Assignment – 4COLLEGE OF COMPUTING AND INFORMATICS Assignment – 4
COLLEGE OF COMPUTING AND INFORMATICS Assignment – 4
 
2-Rainbow Domination of Hexagonal Mesh Networks
2-Rainbow Domination of Hexagonal Mesh Networks2-Rainbow Domination of Hexagonal Mesh Networks
2-Rainbow Domination of Hexagonal Mesh Networks
 
AP Calculus Slides December 10, 2007
AP Calculus Slides December 10, 2007AP Calculus Slides December 10, 2007
AP Calculus Slides December 10, 2007
 
Ee693 sept2014quizgt2
Ee693 sept2014quizgt2Ee693 sept2014quizgt2
Ee693 sept2014quizgt2
 
Digit Factorial Chains .(Euler Problem -74) (Matlab Programming Solution)
Digit Factorial Chains .(Euler Problem -74) (Matlab Programming Solution)Digit Factorial Chains .(Euler Problem -74) (Matlab Programming Solution)
Digit Factorial Chains .(Euler Problem -74) (Matlab Programming Solution)
 
Concatenate function in Excel - How to combine cell in Excel
Concatenate function in Excel - How to combine cell in ExcelConcatenate function in Excel - How to combine cell in Excel
Concatenate function in Excel - How to combine cell in Excel
 
Ee693 sept2014quizgt1
Ee693 sept2014quizgt1Ee693 sept2014quizgt1
Ee693 sept2014quizgt1
 
Data Science for Number and Coding Theory
Data Science for Number and Coding TheoryData Science for Number and Coding Theory
Data Science for Number and Coding Theory
 
Minimal Introduction to C++ - Part I
Minimal Introduction to C++ - Part IMinimal Introduction to C++ - Part I
Minimal Introduction to C++ - Part I
 
Session II - Estimation methods and accuracy Li-Chun Zhang Discussion: Sess...
Session II - Estimation methods and accuracy   Li-Chun Zhang Discussion: Sess...Session II - Estimation methods and accuracy   Li-Chun Zhang Discussion: Sess...
Session II - Estimation methods and accuracy Li-Chun Zhang Discussion: Sess...
 
Basic Traversal and Search Techniques
Basic Traversal and Search TechniquesBasic Traversal and Search Techniques
Basic Traversal and Search Techniques
 
Basic Traversal and Search Techniques
Basic Traversal and Search TechniquesBasic Traversal and Search Techniques
Basic Traversal and Search Techniques
 
Lecture 14 data structures and algorithms
Lecture 14 data structures and algorithmsLecture 14 data structures and algorithms
Lecture 14 data structures and algorithms
 
I. AO* SEARCH ALGORITHM
I. AO* SEARCH ALGORITHMI. AO* SEARCH ALGORITHM
I. AO* SEARCH ALGORITHM
 
Combinatorial optimization CO-1
Combinatorial optimization CO-1Combinatorial optimization CO-1
Combinatorial optimization CO-1
 

Destacado (9)

Lab no.06
Lab no.06Lab no.06
Lab no.06
 
matab no9
matab no9matab no9
matab no9
 
communication system Chapter 6
communication system Chapter 6communication system Chapter 6
communication system Chapter 6
 
communication system ch1
communication system ch1communication system ch1
communication system ch1
 
Lab no.07
Lab no.07Lab no.07
Lab no.07
 
communication system Chapter 5
communication system Chapter 5communication system Chapter 5
communication system Chapter 5
 
communication system Chapter 3
communication system Chapter 3communication system Chapter 3
communication system Chapter 3
 
communication system Chapter 4
communication system Chapter 4communication system Chapter 4
communication system Chapter 4
 
communication system Chapter 2
communication system Chapter 2communication system Chapter 2
communication system Chapter 2
 

Similar a matab no4

Paper computer
Paper computerPaper computer
Paper computer
bikram ...
 
Paper computer
Paper computerPaper computer
Paper computer
bikram ...
 
Neuro -fuzzy-networks-for-identification-of-mathematical-model-parameters-of-...
Neuro -fuzzy-networks-for-identification-of-mathematical-model-parameters-of-...Neuro -fuzzy-networks-for-identification-of-mathematical-model-parameters-of-...
Neuro -fuzzy-networks-for-identification-of-mathematical-model-parameters-of-...
Cemal Ardil
 

Similar a matab no4 (20)

python.ppt
python.pptpython.ppt
python.ppt
 
Perm winter school 2014.01.31
Perm winter school 2014.01.31Perm winter school 2014.01.31
Perm winter school 2014.01.31
 
MatLab Basic Tutorial On Plotting
MatLab Basic Tutorial On PlottingMatLab Basic Tutorial On Plotting
MatLab Basic Tutorial On Plotting
 
Paper computer
Paper computerPaper computer
Paper computer
 
Paper computer
Paper computerPaper computer
Paper computer
 
python.ppt
python.pptpython.ppt
python.ppt
 
Neuro -fuzzy-networks-for-identification-of-mathematical-model-parameters-of-...
Neuro -fuzzy-networks-for-identification-of-mathematical-model-parameters-of-...Neuro -fuzzy-networks-for-identification-of-mathematical-model-parameters-of-...
Neuro -fuzzy-networks-for-identification-of-mathematical-model-parameters-of-...
 
Chapter 1 MATLAB Fundamentals easy .pptx
Chapter 1 MATLAB Fundamentals easy .pptxChapter 1 MATLAB Fundamentals easy .pptx
Chapter 1 MATLAB Fundamentals easy .pptx
 
Seminar PSU 10.10.2014 mme
Seminar PSU 10.10.2014 mmeSeminar PSU 10.10.2014 mme
Seminar PSU 10.10.2014 mme
 
Seminar psu 20.10.2013
Seminar psu 20.10.2013Seminar psu 20.10.2013
Seminar psu 20.10.2013
 
python.ppt
python.pptpython.ppt
python.ppt
 
L08.pdf
L08.pdfL08.pdf
L08.pdf
 
gmrit-cse
gmrit-csegmrit-cse
gmrit-cse
 
Matlab-free course by Mohd Esa
Matlab-free course by Mohd EsaMatlab-free course by Mohd Esa
Matlab-free course by Mohd Esa
 
python(1).ppt
python(1).pptpython(1).ppt
python(1).ppt
 
Deep Learning, Keras, and TensorFlow
Deep Learning, Keras, and TensorFlowDeep Learning, Keras, and TensorFlow
Deep Learning, Keras, and TensorFlow
 
Python basics
Python basicsPython basics
Python basics
 
raster algorithm.pdf
raster algorithm.pdfraster algorithm.pdf
raster algorithm.pdf
 
Clustering-beamer.pdf
Clustering-beamer.pdfClustering-beamer.pdf
Clustering-beamer.pdf
 
python.ppt
python.pptpython.ppt
python.ppt
 

Último

The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 

Último (20)

Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 

matab no4

  • 1. Lab No.04 MATLAB graphics Designed by : Dawar Awan dawar@cecos.edu.pk CECOS College of Engineering and IT March – July 2012
  • 2. Discrete signals  Plot the discrete signal x = [1 2 3 4] in MATLAB 4 3 2 1 -1 0 1 2  using stem(x) plots the signal starting from index number 1 CECOS College of Engineering and IT March – July 2012
  • 3. Practice  Plot the following discrete time sequences x[n]=[1 1 1 1 2 1 1 1 1] x[n]=[5 4 3 2 1 0 1 2 3 4 5] CECOS College of Engineering and IT March – July 2012
  • 4. Continuous plot  >> plot(n,x)  Shows a continuous plot of x  Actually the discrete points are only connected with straight lines. CECOS College of Engineering and IT March – July 2012
  • 5. Labeling the plot  Example: CECOS College of Engineering and IT March – July 2012
  • 6. Labeling the plot CECOS College of Engineering and IT March – July 2012
  • 7. Multiple plots  Using single “plot” instruction  Example: x = 0:0.01:5; y1=sin(x); y2=sin(2*x); y3=sin(4*x); plot(x,y1,x,y2,x,y3) CECOS College of Engineering and IT March – July 2012
  • 8. Multiple plots CECOS College of Engineering and IT March – July 2012
  • 9. Multiple plots  Using multiple “plot” instructions  Example: x = 0:0.01:5; y1=sin(x); y2=sin(2*x); y3=sin(4*x); plot(x,y1); hold on; plot(x,y2); plot(x,y3); CECOS College of Engineering and IT March – July 2012
  • 10. Multiple plots CECOS College of Engineering and IT March – July 2012
  • 11. Changing default plot settings  Example: x = 0:0.1:5; y1=sin(x); y2=sin(2*x); y3=sin(4*x); plot(x,y1,’+’,x,y2,':',x,y3,‘--'); CECOS College of Engineering and IT March – July 2012
  • 12. Changing default plot settings CECOS College of Engineering and IT March – July 2012
  • 13. Changing default plot settings  line types and mark types Linetypes : solid (-), dashed (--), dotted (:), dashdot (-.) Marktypes : point (.), plus (+), star (*), circle (o), x-mark (x) Check the help of “plot” for more effects. CECOS College of Engineering and IT March – July 2012
  • 14. Axis command  Used to manually zoom axis  axis([xmin xmax ymin ymax])  Example: CECOS College of Engineering and IT March – July 2012
  • 15. Axis command  Without axis command CECOS College of Engineering and IT March – July 2012
  • 16. Axis command  With axis command CECOS College of Engineering and IT March – July 2012
  • 17. SUBPLOT  Example: x = 0:1:10; y = x.^2; z = 10*x; subplot (1,2,1) plot(x,y) subplot (1,2,2) plot(x,z) subplot(m,n,p) : makes m rows and n columns of figures in figure window and p shows the location of the current plot i.e the plot instruction just below the subplot CECOS College of Engineering and IT March – July 2012
  • 18. SUBPLOT CECOS College of Engineering and IT March – July 2012
  • 19. Generating a sine wave  Example: creating a 5Hz sine wave, sampled at 8000Hz. f=5; fs=8000; t=[0:1/fs:1]; y=sin(2*pi*f*t); plot(t,y); CECOS College of Engineering and IT March – July 2012
  • 20. Generating a sine wave  Observe 5 cycles per second. CECOS College of Engineering and IT March – July 2012
  • 21. Generating a sine wave  Example: Creating a 1000Hz sine wave, sampled at 8000Hz, and routing it to computer’s soundcard. f=1000; fs=8000; t=[0:1/fs:3]; y=sin(2*pi*f*t); sound(y,fs); The sound will be heard for 3 seconds, as dictated by the code CECOS College of Engineering and IT March – July 2012
  • 22. Task 1. Plot the two curves y1 = x2 and y2 = 2x on the same graph using different plot styles. Label the plot properly 2. Write a MATLAB program that adds the following two signals, Plot the original signals as well as their sum. x1[n] = [2 2 2 2 2] x2[n] = [2 2 2 2 0 0] 3. Scale the amplitude of the following signal by a factor of 2 and ½ and show the scaled signals along with the original. x(t) = sin(t) + 1/3sin(3t) CECOS College of Engineering and IT , t=0:0.01:10 March – July 2012
  • 23. Tasks 4. Demonstrate the use of the function ”plot3” to plot a straight 3D line CECOS College of Engineering and IT March – July 2012