Professional Documents
Culture Documents
LK 2
LK 2
MATLAB 2D 3D
, , animation-
.
Plotting
Command Window-
.
, .
MATLAB- ,
.
.
2
.
.
2 line, bar, histogram, pie
.
xvalues, yvalues 2
.
plot(xvalue, yvalue,style-option)
, ,
x = 0:pi/100:2*pi;
y = sin(x);
plot(x,y)
style-option
Color Style-option
Line Style-option
Marker Style-option
yellow
solid
plus sign
magenta
--
dashed
circle
cyan
dotted
asterisk
red
-.
dash-dot
x-mark
green
point
blue
up triangle
white
square
black
diamond
y=2e-0.5xcos(4x)
0x2
>> x=0:pi/100:2*pi;
>> y=2*exp(-0.5*x).*cos(4*pi*x);
>> plot(x,y)
2
1.5
1
0.5
0
-0.5
-1
-1.5
-2
xlabel(
ylabel(
)
')
title (
legend(
x
y
)
1, 2 3-
Text(2,6,
(2.0,6.0)
FIGURE
TITLE
YLABEL
LEGEND
TEXT
or
GTEXT
CURVES
XLABEL
0x2
y2=cos(4x)y1=2e-0.5x
>> x=0:pi/100:2*pi;
>> y1=2*exp(-0.5*x);
>> y2=cos(4*pi*x);
>> plot(x,y1,x,y2)
>> title('x from 0 to 2{\pi}');
>> xlabel('Variable X');
>> ylabel('Variable Y');
>> text(0.8,1.5,'y1=2e^{-0.5x}');
>> text(2.5,1.1,'y2=cos(4{\pi}x)');
>> legend('y1',' y2')
x from 0 to 2
y1
y2
-0.5x
1.5
y1=2e
y2=cos(4x)
1
Y
le
b
a
ir
a
V
0.5
-0.5
-1
3
4
Variable X
>> x=0:0.01:pi/2;
>> plot(x,tan(x))
>>grid on
1400
1200
1000
800
600
400
200
0
0.2
0.4
0.6
0.8
1.2
1.4
1.6
axis([xmin,xmax,ymin,ymax])
>> axis([0,pi/2,0,15])
>>grid off
15
10
0.5
1.5
FIGURE PLOT-
HOLD ON
HOLD OFF
>> x = 0:.1:2*pi;
>> y = sin(x);
>> plot(x,y)
>> grid on
>> hold on
>> plot(x,exp(-x),'r:*')
Subplots function
>> x=0:pi/10:2*pi;
>> y=2*sin(x);
>> subplot(2,2,1);
>> plot(x,y);
>> t=0:pi/50:2*pi;
>> r=sin(t).*cos(t);
>> subplot(2,2,2);
>> polar(t,r)
>> subplot(2,2,3);
>> pie([2347,1827,2043,3025]);
>> subplot(2,2,4);
>> bar([5 6 7; 3 9 8;2 4 9])
120
150
180
210
-1
-2
90 0.5
60
0.25 30
330
240
270
300
10
25%
33%
8
6
4
20%
2
22%
CLIPBOARD
Copying to Clipboard:
1
Options:
(Edit / Copy Options)
Copying:
(Edit / Copy Figure)
0.9
2-D Plots
Sine Wave
Decaying Exponential
<--Sin( /3)
0.8
0.7
0.6
t)( 0.5
in
S
0.4
0.3
0.2
0.1
0
3
Time
COPY OPTIONS
, (sine wave)
ctrl-x
- cut object
ctrl-c
- copy object
delete - remove object
3
plot(xvalue, yvalue, zvalue,style-option)
>> z = 0:0.1:40;
>> x = cos(z);
>> y = sin(z);
>> plot3(x,y,z)
>> subplot(2,2,1);
>> ezplot('x^2-y^4')
>> subplot(2,2,2);
>> ezsurf('x^2+y^2')
>> subplot(2,2,3:4);
>> ezpolar('1+cos(t)')
2 4
x +y
x -y = 0
80
60
40
20
-2
-4
-6
5
0
-6
-4
-2
0
x
120
90 2
60
150
30
180
210
330
240
270
r = 1+cos(t)
300
-5
-5
0
x
5
10
-10
5
0
-5
-5
-4
-5
2
0
-2
-2
-4
-6
-5
>> subplot(2,2,1);
>> [x,y,z] =
ellipsoid(0,0,0,4,5,6);
>> surf(x,y,z);
>> subplot(2,2,2);
>> contour(x,y,z);
>> subplot(2,2,3);
>> contour(y,z,x);
>> subplot(2,2,4);
>> contour(z,x,y);
-2
-4
-6
-4
-2
30
15
20
10
10
0
-10
0
50
20
0
-50
-20
-30
-20
-20
-10
10
20
12
10
10
8
0
6
4
-10
2
0
-30
-20
-10
[X,Y] = meshgrid(-20:.2:20,-30:.2:30);
Z=sqrt(X.^2/5+Y.^2/9-1);
subplot(2,2,1);
mesh(X,Y,Z);
subplot(2,2,2);
contour(X,Y,Z);
subplot(2,2,3);
contour(Y,Z,X);
subplot(2,2,4);
contour(Z,X,Y);
10
20
30
-20
10
20