Professional Documents
Culture Documents
Matlab Plot
Matlab Plot
n
n
plot :
x y
x = linspace(0, 2*pi);
% 0 2 100
y = sin(x);
% x
plot(x, y);
1
0.8
0.6
0.4
0.2
0
-0.2
(Index)
-0.4
-0.6
-0.8
-1
x y plot
x = linspace(0, 2*pi);
% 0 2 100
1.5
0.5
-0.5
-1
-1.5
plot
x y (Linear Scale)
loglog
x y (Logarithmic Scale)
semilogx
x y
semilogy
x y
plotyy
semilogx
n
x = linspace(0, 8*pi);
semilogx(x, sin(x));
% 0 8 100
% x
1
0.8
0.6
0.4
0.2
0
-0.2
-0.4
-0.6
-0.8
-1
-1
10
10
10
10
plotyy
n
x = linspace(0, 2*pi);
% 0 2 100
y1 = sin(x);
y2 = exp(-x);
plotyy(x, y1, x, y2); % y y1, y2
1
0.5
y2
y1
-1
0
7
plot
n
n
plot(x, y, CLM)
n
n
n
C(Colors)
L(Line Styles)
M(Markers)
x = 0:0.5:4*pi;
y = sin(x);
plot(x, y,k:diamond)
% k
% diamond
%
1
0.8
0.6
0.4
0.2
0
-0.2
-0.4
-0.6
-0.8
-1
10
12
14
plot
Plot
RGB
(Blue)
(0,0,1)
(Cyan)
(0,1,1)
(Green)
(0,1,0)
(Black)
(0,0,0)
(Magenta)
(1,0,1)
(Red)
(1,0,0)
(1,1,1)
(Yellow)
(1,1,0)
plot
plot
()
--
-.
plot
plot
>
<
square
diamond
pentagram
hexagram
n
n
plot
axis
n
n
n
grid box
n
grid on
grid off
box on
box off
y 0 1
x = 0:0.1:4*pi;
y = sin(x);
plot(x, y);
axis([-inf, inf, 0, 1]);
% y 0 1
grid on;
1
0.9
0.8
inf
( x
)
0.7
0.6
0.5
0.4
0.3
0.2
0.1
0
10
12
title
xlabel
ylabel
zlabel
z ()
legend
text
gtext
x = 0:0.1:2*pi;
y1 = sin(x);
plot(x, y1, '--*', x, y2, ':o');
xlabel('time');
ylabel('values of sin(t) and exp(-x)')
title('Function Plots of sin(t) and exp(-x)');
legend('sin(t)','exp(-x)');
0.6
values of sin(t) and exp(-x)
y2 = exp(-x);
sin(t)
exp(-x)
0.8
0.4
0.2
0
-0.2
-0.4
-0.6
-0.8
-1
4
time
text
n
n
n
text(x, y, string)
xy
string
1
x = 0:0.1:2*pi;
plot(x, sin(x), x, cos(x));
text(0.2, 0, 'sin(x)')
text(0.5*pi+0.2, 0, 'cos(x)')
0.8
0.6
0.4
0.2
0
sin(x)
cos(x)
-0.2
-0.4
-0.6
-0.8
-1
gtext
n
n
n
gtext(string)
string
gtext
subplot
n
n
n
n
n
()
subplot (m, n, p)
m n
plot p
p
x = 0:0.1:4*pi;
subplot(2, 2, 1); plot(x, sin(x));
subplot(2,2,1)
0.5
0.5
-0.5
-0.5
-1
10
15
10
15
200
150
0.5
subplot(2,2,3)
-1
subplot(2,2,2)
100
0
-0.5
subplot(2,2,4)
50
10
15
10
15
- errorbar
n
errorbar:
n
y 20%
x = linspace(0,2*pi,30);
% 0 2 30
y = sin(x);
e = y*0.2;
errorbar(x,y,e)
% e
1.5
0.5
-0.5
-1
-1.5
-1
- fplot
n
fplot:
n
% [0.02 0.2]
1
0.8
0.6
0.4
0.2
0
-0.2
-0.4
-0.6
-0.8
-1
0.02
0.04
0.06
0.08
0.1
0.12
0.14
0.16
0.18
0.2