SlideShare uma empresa Scribd logo
1 de 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

Mais conteúdo relacionado

Semelhante a lect.no.3.pptx

Matlab level 1.pptx
Matlab level 1.pptxMatlab level 1.pptx
Matlab level 1.pptx
AbanobGozef
 
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
agnesdcarey33086
 
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
 
INTRODUCTION TO MATLAB presentation.pptx
INTRODUCTION TO MATLAB presentation.pptxINTRODUCTION TO MATLAB presentation.pptx
INTRODUCTION TO MATLAB presentation.pptx
Devaraj Chilakala
 
Introduction to MatLab programming
Introduction to MatLab programmingIntroduction to MatLab programming
Introduction to MatLab programming
Damian T. Gordon
 

Semelhante a 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
 

Último

VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
dharasingh5698
 

Último (20)

MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
 
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...
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxBSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdf
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptx
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
Glass Ceramics: Processing and Properties
Glass Ceramics: Processing and PropertiesGlass Ceramics: Processing and Properties
Glass Ceramics: Processing and Properties
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
 
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 Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
MANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTING
MANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTINGMANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTING
MANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTING
 
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur EscortsRussian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
 
UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduits
 
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
 

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