SlideShare ist ein Scribd-Unternehmen logo
1 von 25
1
Graphics and
Plotting
Outline:
 Matlab graphics and plotting
 Plotting Process
 Graph Components
 Figure Tools
 Arranging Graphs Within a Figure
 Choosing a Type of Graph to Plot
 Using of M-File
 Sub-Plots (different diagrams)
 3D-plot
2
Plot command
 plot( ) Command creates a graphic from vectors, with
linear scales on two or three axes
plot3(X,Y,Z, 'option') %3-D plot.
plot(X1,Y1, . . . 'option') %2-D plot , one curve
plot(X,Y1, X, Y2, X, Y3, . . . 'option')
%2-D plot, Multi-curves to the same y-axis
Option is Line styles (Type, markers and color)
3
Plot command (line style)
 Line style include
 Line type,
 Marker symbol, and
 color
 Example
>> plot(x,exp(-x),'g--s') 4
Class activity
 Create an x-array samples with step 0.01.
 Calculate sin x of the x-array
 Calculate sin(x) of the x-array
>>x= 0 : 0.01:4*pi;
>>y=sin(x);
>>plot (x,y, ‘r -. *')
5
 Plot the function sin(x) between 0 ≤ x ≤ 4π
6
7
Linspace command-01
 linspace: This function generates a vector of uniformly
incremented values (i.e. Linearly spaced vector).
 This function Syntax has the form:
linspace (start , end [ , number ] )
The default value if number not specified is 100
 The increment is computed internally, having the value:
 Example: linspace (0, π,11)
8
)
1
( 


number
start
end
increment


1
.
0
)
1
11
(
0




increment
Linspace command-02
 y = linspace(a,b) generates a row vector y
of 100 points linearly spaced between and
including a and b.
 y = linspace(a,b,n) generates a row vector
y of n points linearly spaced between and
including a and b.
 For n < 2, LINSPACE returns b.
(Ex.) >> linspace(0,4,2)
ans =
0 4 9
10
>> linspace(1,5,4)
ans =
1.0000 2.3333 3.6667 5.0000
>> linspace(0,6,3)
ans =
0 3 6
>> linspace(3,9,4)
ans =
3 5 7 9
>> linspace(3,9,2)
ans =
3 9
Class activity
>>x=linspace(0 , 4*pi);
>>y=sin(x);
>>plot(x,y, ‘b :')
11
 2- Calculate sin() of the x-array
 Plot the y-array
 1- Create an x-array of 100 samples with step 4π.
 Plot the function sin(x) between 0 ≤ x ≤ 4π of 100
linearly equal spaced points
0 2 4 6 8 10 12 14
-1
-0.8
-0.6
-0.4
-0.2
0
0.2
0.4
0.6
0.8
1
Class activity- M-file
% program indicating plot options
x = -pi:pi/10:pi;
y = tan(sin(x)) - sin(tan(x));
plot(x,y,’--rs’,'MarkerEdgeColor','k',...
'MarkerFaceColor','g',...
'MarkerSize',10);
12
Class activity- Output figure
13
-4 -3 -2 -1 0 1 2 3 4
-3
-2
-1
0
1
2
3
Graph Annotation
14
TITLE
TEXT
or
GTEXT
XLABEL
YLABEL
LEGEND
Display Facilities - GUI
 title(‘text strings’)
 xlabel(‘text strings’)
 ylabel(‘text strings’)
>>title( ' This is the sinus function' )
>>xlabel( ‘ x (secs) ')
>>ylabel( ‘ sin(x) ')
0 10 20 30 40 50 60 70 80 90 100
-1
-0.8
-0.6
-0.4
-0.2
0
0.2
0.4
0.6
0.8
1
This is the sinus function
x (secs)
sin(x)
15
Matlab Graphics- Class activity
x = 0 : pi/100 : 2*pi;
y = sin(x);
plot(x,y)
xlabel('x = 0:2π ')
ylabel('Sine of x')
title('Plot of the Sine
Function')
16
Displaying text on diagram -01
 To place places 'text‘ on the specific coordinates x
and y text(x,y,' text ')
17
 Example
>> text(5,10, ' logarithmic function ' )
>> text (10,20, ' theta gama ' )
 To place text with help of the mouse on a figure use
gtext(string) ≡ gtext( ' text ' )
Displaying text on diagram -02
t = 0:.01:2*pi;
plot (t,sin(t), '.- r')
xlabel(' theta in radians ' )
ylabel(' sin (theta) ' )
title ( ' plotting the area under a curve ' )
gtext ( ' linear function' )
grid
18
Displaying text on diagram -03
19
0 1 2 3 4 5 6 7
-1
-0.8
-0.6
-0.4
-0.2
0
0.2
0.4
0.6
0.8
1
 in radians
sin
(
theta)
plotting the area under a curve
linear function
Display Facilities (plot vs. stem)
 Plot( )
 Stem( )
x=linspace(0, 4*pi ,100);
y=sin(x);
plot(x,y)
stem(x,y)
0 10 20 30 40 50 60 70 80 90 100
-0.3
-0.2
-0.1
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0 10 20 30 40 50 60 70 80 90 100
-0.3
-0.2
-0.1
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
20
Display Facilities (bar chart)
 The form is bar(x_value, Y_value)
21
clf
x = 1:5;
y1 = [2 11 6 9 3];
bar(x,y1)
1 2 3 4 5
0
2
4
6
8
10
12
Display Facilities (bar vs. plot)
 a bar chart.
22
clf
x = 1:5;
y1 = [2 11 6 9 3];
figure(1) % Put a bar chart in Figure 1
bar(x,y1)
figure(2) % Put plots on one plot with a legend
plot(x,y1, 'k') ,hold on
y2 = [4 5 8 6 2]; % better to written after y1
plot(x,y2, 'ro') ,grid on
legend('y1' , 'y2')
Display Facilities (bar vs. plot)
23
Adding additional plots to a
figure
24
•HOLD ON holds the current
plot
•HOLD OFF releases hold on
current plot
•HOLD toggles the hold state
x = 0 : 0.1 : 2*pi;
y = sin(x);
plot(x,y,' b ')
grid on;
hold on;
plot(x,exp(-x), ' r : * ');
Multiple Graphs (same
diagram)
t = 0:pi/100:2*pi;
y1=sin(t);
y2=sin(t + pi/2);
plot(t,y1,t,y2)
grid on
25
plot(X,Y1,X,Y2)
 plots Y1 versus X and plots Y2 versus X with y-axis
labeling on the left for both curves.
0 1 2 3 4 5 6 7
-1
-0.8
-0.6
-0.4
-0.2
0
0.2
0.4
0.6
0.8
1

Weitere ähnliche Inhalte

Ähnlich wie lect.no.3.pptx

Matlab level 1.pptx
Matlab level 1.pptxMatlab level 1.pptx
Matlab level 1.pptxAbanobGozef
 
SAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docx
SAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docxSAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docx
SAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docxagnesdcarey33086
 
Python matplotlib cheat_sheet
Python matplotlib cheat_sheetPython matplotlib cheat_sheet
Python matplotlib cheat_sheetNishant Upadhyay
 
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 VyacheslavVyacheslav Arbuzov
 
Programs in array using SWIFT
Programs in array using SWIFTPrograms in array using SWIFT
Programs in array using SWIFTvikram mahendra
 
Matlab plotting
Matlab plottingMatlab plotting
Matlab plottingpink1710
 
Computer Graphics in Java and Scala - Part 1
Computer Graphics in Java and Scala - Part 1Computer Graphics in Java and Scala - Part 1
Computer Graphics in Java and Scala - Part 1Philip Schwarz
 
INTRODUCTION TO MATLAB presentation.pptx
INTRODUCTION TO MATLAB presentation.pptxINTRODUCTION TO MATLAB presentation.pptx
INTRODUCTION TO MATLAB presentation.pptxDevaraj Chilakala
 
INTRODUCTION TO MATLAB session with notes
  INTRODUCTION TO MATLAB   session with  notes  INTRODUCTION TO MATLAB   session with  notes
INTRODUCTION TO MATLAB session with notesInfinity Tech Solutions
 
Introduction to MatLab programming
Introduction to MatLab programmingIntroduction to MatLab programming
Introduction to MatLab programmingDamian T. Gordon
 
Advanced Data Visualization Examples with R-Part II
Advanced Data Visualization Examples with R-Part IIAdvanced Data Visualization Examples with R-Part II
Advanced Data Visualization Examples with R-Part IIDr. Volkan OBAN
 
BUilt in Functions and Simple programs in R.pdf
BUilt in Functions and Simple programs in R.pdfBUilt in Functions and Simple programs in R.pdf
BUilt in Functions and Simple programs in R.pdfkarthikaparthasarath
 

Ähnlich wie lect.no.3.pptx (20)

Matlab level 1.pptx
Matlab level 1.pptxMatlab level 1.pptx
Matlab level 1.pptx
 
ML-CheatSheet (1).pdf
ML-CheatSheet (1).pdfML-CheatSheet (1).pdf
ML-CheatSheet (1).pdf
 
SAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docx
SAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docxSAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docx
SAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docx
 
Python matplotlib cheat_sheet
Python matplotlib cheat_sheetPython matplotlib cheat_sheet
Python matplotlib cheat_sheet
 
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
 
bobok
bobokbobok
bobok
 
Introduction to MATLAB
Introduction to MATLABIntroduction to MATLAB
Introduction to MATLAB
 
Matlab graphics
Matlab graphicsMatlab graphics
Matlab graphics
 
Programs in array using SWIFT
Programs in array using SWIFTPrograms in array using SWIFT
Programs in array using SWIFT
 
Matlab plotting
Matlab plottingMatlab plotting
Matlab plotting
 
raster algorithm.pdf
raster algorithm.pdfraster algorithm.pdf
raster algorithm.pdf
 
20100528
2010052820100528
20100528
 
20100528
2010052820100528
20100528
 
Computer Graphics in Java and Scala - Part 1
Computer Graphics in Java and Scala - Part 1Computer Graphics in Java and Scala - Part 1
Computer Graphics in Java and Scala - Part 1
 
INTRODUCTION TO MATLAB presentation.pptx
INTRODUCTION TO MATLAB presentation.pptxINTRODUCTION TO MATLAB presentation.pptx
INTRODUCTION TO MATLAB presentation.pptx
 
INTRODUCTION TO MATLAB session with notes
  INTRODUCTION TO MATLAB   session with  notes  INTRODUCTION TO MATLAB   session with  notes
INTRODUCTION TO MATLAB session with notes
 
purrr.pdf
purrr.pdfpurrr.pdf
purrr.pdf
 
Introduction to MatLab programming
Introduction to MatLab programmingIntroduction to MatLab programming
Introduction to MatLab programming
 
Advanced Data Visualization Examples with R-Part II
Advanced Data Visualization Examples with R-Part IIAdvanced Data Visualization Examples with R-Part II
Advanced Data Visualization Examples with R-Part II
 
BUilt in Functions and Simple programs in R.pdf
BUilt in Functions and Simple programs in R.pdfBUilt in Functions and Simple programs in R.pdf
BUilt in Functions and Simple programs in R.pdf
 

Kürzlich hochgeladen

Hostel management system project report..pdf
Hostel management system project report..pdfHostel management system project report..pdf
Hostel management system project report..pdfKamal Acharya
 
kiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal loadkiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal loadhamedmustafa094
 
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.pptNANDHAKUMARA10
 
Hospital management system project report.pdf
Hospital management system project report.pdfHospital management system project report.pdf
Hospital management system project report.pdfKamal Acharya
 
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...drmkjayanthikannan
 
Online food ordering system project report.pdf
Online food ordering system project report.pdfOnline food ordering system project report.pdf
Online food ordering system project report.pdfKamal Acharya
 
Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxJuliansyahHarahap1
 
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Arindam Chakraborty, Ph.D., P.E. (CA, TX)
 
Online electricity billing project report..pdf
Online electricity billing project report..pdfOnline electricity billing project report..pdf
Online electricity billing project report..pdfKamal Acharya
 
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdfAldoGarca30
 
DeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesDeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesMayuraD1
 
A Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityA Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityMorshed Ahmed Rahath
 
AIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech studentsAIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech studentsvanyagupta248
 
PE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and propertiesPE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and propertiessarkmank1
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptDineshKumar4165
 
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
COST-EFFETIVE  and Energy Efficient BUILDINGS ptxCOST-EFFETIVE  and Energy Efficient BUILDINGS ptx
COST-EFFETIVE and Energy Efficient BUILDINGS ptxJIT KUMAR GUPTA
 
Moment Distribution Method For Btech Civil
Moment Distribution Method For Btech CivilMoment Distribution Method For Btech Civil
Moment Distribution Method For Btech CivilVinayVitekari
 
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.pdfJiananWang21
 
Verification of thevenin's theorem for BEEE Lab (1).pptx
Verification of thevenin's theorem for BEEE Lab (1).pptxVerification of thevenin's theorem for BEEE Lab (1).pptx
Verification of thevenin's theorem for BEEE Lab (1).pptxchumtiyababu
 

Kürzlich hochgeladen (20)

Hostel management system project report..pdf
Hostel management system project report..pdfHostel management system project report..pdf
Hostel management system project report..pdf
 
kiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal loadkiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal load
 
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
 
Hospital management system project report.pdf
Hospital management system project report.pdfHospital management system project report.pdf
Hospital management system project report.pdf
 
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
 
Online food ordering system project report.pdf
Online food ordering system project report.pdfOnline food ordering system project report.pdf
Online food ordering system project report.pdf
 
Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptx
 
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
 
Online electricity billing project report..pdf
Online electricity billing project report..pdfOnline electricity billing project report..pdf
Online electricity billing project report..pdf
 
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
 
DeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesDeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakes
 
A Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityA Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna Municipality
 
AIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech studentsAIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech students
 
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced LoadsFEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
 
PE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and propertiesPE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and properties
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
 
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
COST-EFFETIVE  and Energy Efficient BUILDINGS ptxCOST-EFFETIVE  and Energy Efficient BUILDINGS ptx
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
 
Moment Distribution Method For Btech Civil
Moment Distribution Method For Btech CivilMoment Distribution Method For Btech Civil
Moment Distribution Method For Btech Civil
 
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
 
Verification of thevenin's theorem for BEEE Lab (1).pptx
Verification of thevenin's theorem for BEEE Lab (1).pptxVerification of thevenin's theorem for BEEE Lab (1).pptx
Verification of thevenin's theorem for BEEE Lab (1).pptx
 

lect.no.3.pptx

  • 2. Outline:  Matlab graphics and plotting  Plotting Process  Graph Components  Figure Tools  Arranging Graphs Within a Figure  Choosing a Type of Graph to Plot  Using of M-File  Sub-Plots (different diagrams)  3D-plot 2
  • 3. Plot command  plot( ) Command creates a graphic from vectors, with linear scales on two or three axes plot3(X,Y,Z, 'option') %3-D plot. plot(X1,Y1, . . . 'option') %2-D plot , one curve plot(X,Y1, X, Y2, X, Y3, . . . 'option') %2-D plot, Multi-curves to the same y-axis Option is Line styles (Type, markers and color) 3
  • 4. Plot command (line style)  Line style include  Line type,  Marker symbol, and  color  Example >> plot(x,exp(-x),'g--s') 4
  • 5. Class activity  Create an x-array samples with step 0.01.  Calculate sin x of the x-array  Calculate sin(x) of the x-array >>x= 0 : 0.01:4*pi; >>y=sin(x); >>plot (x,y, ‘r -. *') 5  Plot the function sin(x) between 0 ≤ x ≤ 4π
  • 6. 6
  • 7. 7
  • 8. Linspace command-01  linspace: This function generates a vector of uniformly incremented values (i.e. Linearly spaced vector).  This function Syntax has the form: linspace (start , end [ , number ] ) The default value if number not specified is 100  The increment is computed internally, having the value:  Example: linspace (0, π,11) 8 ) 1 (    number start end increment   1 . 0 ) 1 11 ( 0     increment
  • 9. Linspace command-02  y = linspace(a,b) generates a row vector y of 100 points linearly spaced between and including a and b.  y = linspace(a,b,n) generates a row vector y of n points linearly spaced between and including a and b.  For n < 2, LINSPACE returns b. (Ex.) >> linspace(0,4,2) ans = 0 4 9
  • 10. 10 >> linspace(1,5,4) ans = 1.0000 2.3333 3.6667 5.0000 >> linspace(0,6,3) ans = 0 3 6 >> linspace(3,9,4) ans = 3 5 7 9 >> linspace(3,9,2) ans = 3 9
  • 11. Class activity >>x=linspace(0 , 4*pi); >>y=sin(x); >>plot(x,y, ‘b :') 11  2- Calculate sin() of the x-array  Plot the y-array  1- Create an x-array of 100 samples with step 4π.  Plot the function sin(x) between 0 ≤ x ≤ 4π of 100 linearly equal spaced points 0 2 4 6 8 10 12 14 -1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1
  • 12. Class activity- M-file % program indicating plot options x = -pi:pi/10:pi; y = tan(sin(x)) - sin(tan(x)); plot(x,y,’--rs’,'MarkerEdgeColor','k',... 'MarkerFaceColor','g',... 'MarkerSize',10); 12
  • 13. Class activity- Output figure 13 -4 -3 -2 -1 0 1 2 3 4 -3 -2 -1 0 1 2 3
  • 15. Display Facilities - GUI  title(‘text strings’)  xlabel(‘text strings’)  ylabel(‘text strings’) >>title( ' This is the sinus function' ) >>xlabel( ‘ x (secs) ') >>ylabel( ‘ sin(x) ') 0 10 20 30 40 50 60 70 80 90 100 -1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1 This is the sinus function x (secs) sin(x) 15
  • 16. Matlab Graphics- Class activity x = 0 : pi/100 : 2*pi; y = sin(x); plot(x,y) xlabel('x = 0:2π ') ylabel('Sine of x') title('Plot of the Sine Function') 16
  • 17. Displaying text on diagram -01  To place places 'text‘ on the specific coordinates x and y text(x,y,' text ') 17  Example >> text(5,10, ' logarithmic function ' ) >> text (10,20, ' theta gama ' )  To place text with help of the mouse on a figure use gtext(string) ≡ gtext( ' text ' )
  • 18. Displaying text on diagram -02 t = 0:.01:2*pi; plot (t,sin(t), '.- r') xlabel(' theta in radians ' ) ylabel(' sin (theta) ' ) title ( ' plotting the area under a curve ' ) gtext ( ' linear function' ) grid 18
  • 19. Displaying text on diagram -03 19 0 1 2 3 4 5 6 7 -1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1  in radians sin ( theta) plotting the area under a curve linear function
  • 20. Display Facilities (plot vs. stem)  Plot( )  Stem( ) x=linspace(0, 4*pi ,100); y=sin(x); plot(x,y) stem(x,y) 0 10 20 30 40 50 60 70 80 90 100 -0.3 -0.2 -0.1 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0 10 20 30 40 50 60 70 80 90 100 -0.3 -0.2 -0.1 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 20
  • 21. Display Facilities (bar chart)  The form is bar(x_value, Y_value) 21 clf x = 1:5; y1 = [2 11 6 9 3]; bar(x,y1) 1 2 3 4 5 0 2 4 6 8 10 12
  • 22. Display Facilities (bar vs. plot)  a bar chart. 22 clf x = 1:5; y1 = [2 11 6 9 3]; figure(1) % Put a bar chart in Figure 1 bar(x,y1) figure(2) % Put plots on one plot with a legend plot(x,y1, 'k') ,hold on y2 = [4 5 8 6 2]; % better to written after y1 plot(x,y2, 'ro') ,grid on legend('y1' , 'y2')
  • 23. Display Facilities (bar vs. plot) 23
  • 24. Adding additional plots to a figure 24 •HOLD ON holds the current plot •HOLD OFF releases hold on current plot •HOLD toggles the hold state x = 0 : 0.1 : 2*pi; y = sin(x); plot(x,y,' b ') grid on; hold on; plot(x,exp(-x), ' r : * ');
  • 25. Multiple Graphs (same diagram) t = 0:pi/100:2*pi; y1=sin(t); y2=sin(t + pi/2); plot(t,y1,t,y2) grid on 25 plot(X,Y1,X,Y2)  plots Y1 versus X and plots Y2 versus X with y-axis labeling on the left for both curves. 0 1 2 3 4 5 6 7 -1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1