MATLAB Graphics MATLAB Graphics
MATLAB Graphics MATLAB Graphics
MATLAB Graphics
1
MATLAB Graphics
MATLAB Graphics
For Academic use only. No commercial use without prior permission of
Plot title
Light Intensity as a Function of Distance
1200
Theory
Experiment
y axis 1000
label
Text
Tick-mark
800
INTENSITY (lux)
600
400
Javaid.Ahmad@nu.edu.pk
Data symbol
200
0
8 10 12 14 16 18 20 22 24
DISTANCE (cm)
x axis Tick-mark label
label
3
MATLAB Graphics
• plot(x,z, 'g:s')
• hold on;
• plot(x,yz, ‘b-’)
4
MATLAB Graphics
• y2=exp(x);
• plotyy(x,y1,x,y2)
5
MATLAB Graphics
Other plots:
To plot single line/vector,
use plot(x)
• e.g. x=0:pi/10:10*pi;
• plot(x)
use Line command
• e.g. x = 0:pi/100:2*pi;
• y1 = sin(x);
• line(x, y1)
Javaid.Ahmad@nu.edu.pk
• x = [1 9];
•y = [2 12];
• line(x,y, ‘color', ‘green', ‘lineStyle','--')
6
MATLAB Graphics
• x = [1 9];
•y = [2 12];
• line(x,y, ‘Color', ‘green', ‘LineStyle','—’)
7
MATLAB Graphics
• oplot=ezplot('(x^2+y^2-1)^3 - x^2*y^3',[-2,2,-1.5,1.5])
• Also have fun with ezsurf()
8
MATLAB Graphics
>> subplot(2,3,4);
m
P=4
Javaid.Ahmad@nu.edu.pk
9
MATLAB Graphics
surf command
• e.g.
• dx = linspace(0,20,3);
• Lx = linspace(0,20,5);
• M = [0 10 20; 10 40 50; 0 100 150; 195 250 300; 0 150
800];
• surf(dx,Lx,M) % Column of dx must match with
columns of M and columns of Lx must match with rows
of M
Javaid.Ahmad@nu.edu.pk
800
600
400
200
0
20
15 20
10 15
10
5 5
0 0
10
MATLAB Graphics
contour command
• e.g.
• dx = linspace(0,20,3);
• Lx = linspace(0,20,5);
• M = [0 10 20; 10 40 50; 0 100 150; 195 250 300; 0 150
800];
• contour(dx,Lx,M)
Javaid.Ahmad@nu.edu.pk
11
For Academic use only. No commercial use without prior permission of
Javaid.Ahmad@nu.edu.pk
12
For Academic use only. No commercial use without prior permission of
Javaid.Ahmad@nu.edu.pk
13
MATLAB Graphics
Plot Formatting
For Academic use only. No commercial use without prior permission of
14
MATLAB Graphics
MATLAB Figure
For Academic use only. No commercial use without prior permission of
15