Professional Documents
Culture Documents
MATLAB 09. Animation을 이용한 시뮬레이션 PDF
MATLAB 09. Animation을 이용한 시뮬레이션 PDF
- Cart
C t type
t
Pendulum
P d l
ml
x cx F
M m
ml
mgl
ml
x M m
ml cx F
ml
mgl f
2
ml
I
x
1
( M m)(mll 2 I ) m 2l 2
ml 2 I
mll
ml cx F
M m mgll f
x
ml 2 I
1
( M m)(ml 2 I ) m 2l 2
ml
x
1
( M m)(mll 2 I ) m 2l 2
x
1
( M m)(ml 2 I ) m 2l 2
ml cx F
M m mgl f
ml
l
(
cx
F
)
(
M
m
)(
mgl
l
mlF
cmlx
mgl
(
M
m
)
(
M
m
)
f
x
1
2
2 2
( M m)(ml I ) m l
mlF
cmlx
mgl
(
M
m
)
(
M
m
)
f
x
1 0.0102 x 9.8 0.01 1.02 F
6.012
F
0.01
58.8
0.06
- Cart
C t type
t
Pendulum
P d l
x
1 0.0102 x 9.8 0.01 1.02 F
6.012
0.01
x
58.8
0.06
F
f(u)
1
s
1
s
Fcn
Integrator
Integrator1
f(u)
1
s
1
s
Fcn1
Integrator2
Integrator3
0
Constant
Scope
-KGain
Scope1
f(u)
( )
1
s
1
s
Fcn
Integrator
Integrator1
f(u)
1
s
1
s
Fcn1
Integrator2
Integrator3
0
Constant
Scope
-KGain
Scope1
f(u)
( )
1
s
1
s
Fcn
Integrator
Integrator1
f(u)
1
s
1
s
Fcn1
Integrator2
Integrator3
0
Constant
Scope
-KGain
Scope1
f(u)
( )
1
s
1
s
Fcn
Integrator
Integrator1
f(u)
1
s
1
s
Fcn1
Integrator2
Integrator3
0
Constant
Scope
-KGain
Scope1
f(u)
( )
1
s
1
s
Fcn
Integrator
Integrator1
f(u)
1
s
1
s
Fcn1
Integrator2
Integrator3
0
Constant
Scope
-KGain
Scope1
f(u)
( )
1
s
1
s
Fcn
Integrator
Integrator1
f(u)
1
s
1
s
Fcn1
Integrator2
Integrator3
0
Constant
Scope
-KGain
Scope1
MATLAB
( r , 0)
(r , 0)
l = 5;
r = 0.1;
x_plane
l
= [[-10
10 -10
10 10 10];
10]
y_plane = [-0.6 -0.5 -0.5 -0.6];
x_cart = [-1 -1 1 1];
y_cart = [-0.5 0.5 0.5 -0.5];
x_pole
l = [[-r -r r r];
]
y_pole = [-l 0 0 -l];
(r , l )
( r , l )
l cos , l sin
l cos , l sin
( r , 0)
(r , 0)
tan 1
r
l
3
3
1 r
1 r
l cos 2 tan l , l sin 2 tan l
(r , l )
( r , l )
3
3
1 r
1 r
l
cos
tan
,
l
sin
tan
l
l
2
2
l = 5;
r = 0.1;
-2
-4
-6
-8
-10
-8
-6
-4
-2
for t = 0:0.01:20*pi/180
updatedX cart = x_cart
updatedX_cart
x cart + t;
temp_x = [l*cos(3/2*pi+t-atan(r/l)) r*cos(pi+t) r*cos(t) l*cos(3/2*pi+t+atan(r/l))];
temp_y = [l*sin(3/2*pi+t-atan(r/l)) r*sin(pi+t) r*sin(t) l*sin(3/2*pi+t+atan(r/l))];
updatedX_pole = t + temp_x;
updatedY_pole = temp_y;
set(cart,
t( t 'Xdata',
'Xd t ' updatedX_cart);
d t dX
t)
set(pole, 'Xdata', updatedX_pole,'Ydata', updatedY_pole);
drawnow;
for i=1:5000000
temp = i;
end
end
10
MATLAB
f(u)
1
s
1
s
Fcn
Integrator
Integrator1
f(u)
1
s
1
s
Fcn1
Integrator2
Integrator3
0
Constant
Scope
-KGain
Scope1
cart
Click Here
pole
p
MATLAB
Function
MATLAB Fcn
Terminator
f(u)
1
s
1
s
Fcn
Integrator
Integrator1
f( )
f(u)
1
s
1
s
Fcn1
Integrator2
Integrator3
0
Constant
Scope
-KK
Gain
Scope1
cart
Click Here
pole
MATLAB
Function
MATLAB Fcn
Terminator
l = 5;
r = 0.1;
x plane = [[-10
x_plane
10 -10
10 10 10];
y_plane = [-0.6 -0.5 -0.5 -0.6];
x_cart = [-1 -1 1 1];
y cartt = [[-0.5
y_ca
0.5 0.5 0.5 -0.5];
0.5];
x_pole = [-r -r r r];
y_pole = [-l 0 0 -l];
plane = fill(x_plane,
p
( p
yy_plane,
p
'k');
)
grid on
hold on
cart = fill(x_cart, y_cart, 'g','EraseMode','normal');
pole = fill(x_pole, y_pole, 'b','EraseMode','normal');
hold off
axis([-10 10 -8 4]);
f(u)
1
s
1
s
Fcn
Integrator
Integrator1
f( )
f(u)
1
s
1
s
Fcn1
Integrator2
Integrator3
0
Constant
Scope
-KK
Gain
Scope1
cart
Click Here
pole
MATLAB
Function
MATLAB Fcn
Terminator
f(u)
1
s
1
s
Fcn
Integrator
Integrator1
f( )
f(u)
1
s
1
s
Fcn1
Integrator2
Integrator3
0
Constant
Scope
-KK
Gain
Scope1
cart
Click Here
pole
MATLAB
Function
MATLAB Fcn
Terminator
function y = test1(pos_cart,
test1(pos cart theta,
theta cart,
cart pole)
l = 5;
r = 0.1;
x_cart = [-1 -1 1 1];
updatedX
p
_cart = x_cart + p
pos_cart;;
temp_x = [l*cos(3/2*pi+theta-atan(r/l)) r*cos(pi+theta) r*cos(theta)
l*cos(3/2*pi+theta+atan(r/l))];
temp_y
p y = [l*sin(3/2*pi+theta-atan(r/l))
p
r*sin(pi+theta)
p
r*sin(theta)
l*sin(3/2*pi+theta+atan(r/l))];
updatedX_pole = pos_cart + temp_x;
updatedY_pole = temp_y;
set(cart, 'Xdata', updatedX_cart);
set(pole, 'Xdata', updatedX_pole,'Ydata', updatedY_pole);
drawnow;
y = 1;
MATLAB
LQR
- LQR
x
0 0102 x 99.8
8 00.01
01 11.02
02 F
1 0.0102
6.012
x
F
0.01
58.8
0.06
1
0
0 x 0
x 0
0 0.0017 1.6301 0.0017 x 0.1697
x
F
0
0
0
1 0
0.0017
9.7804
0.01
0.1663
1
0
0
0
0
0 0.0017 1.6301 0.0017
0.1697
, B
A
0
0
0
0
1
0
0.0017
9.7804
0.01
0.1663
1
0
Q
0
0 0 0
0 0 0
, R 0.01
0 5 0
0 0 0
K = lqr(A,B,Q,R)
>>
>>
>>
>>
>>
K=
10.0000
13.0808
12.7367
3.2320
Click Here
f(u)
1
s
1
s
Fcn
Integrator
Integrator1
f(u)
1
s
1
s
Fcn1
Integrator2
Integrator3
Gain1
Scope
p
-K-
cart
K*u
pole
Gain
Scope1
MATLAB
Function
MATLAB Fcn
T
Terminator
i
Click Here
f(u)
1
s
1
s
Fcn
Integrator
Integrator1
f(u)
1
s
1
s
Fcn1
Integrator2
Integrator3
Gain1
Scope
p
-K-
cart
K*u
pole
Gain
Scope1
MATLAB
Function
MATLAB Fcn
T
Terminator
i
Click Here
f( )
f(u)
1
s
1
s
Fcn
Integrator
Integrator1
Scope
Scope2
f(u)
1
s
1
s
Fcn1
Integrator2
Integrator3
Gain1
-K-
cart
K*u
pole
Gain
Scope1
MATLAB
Function
MATLAB Fcn
Terminator
Click Here
f( )
f(u)
1
s
1
s
Fcn
Integrator
Integrator1
Scope
Scope2
f(u)
1
s
1
s
Fcn1
Integrator2
Integrator3
Gain1
-K-
cart
K*u
pole
Gain
Scope1
MATLAB
Function
MATLAB Fcn
Terminator
Click Here
f( )
f(u)
1
s
1
s
Fcn
Integrator
Integrator1
Scope
Scope2
f(u)
1
s
1
s
Fcn1
Integrator2
Integrator3
Gain1
-K-
cart
K*u
pole
Gain
Scope1
MATLAB
Function
MATLAB Fcn
Terminator
Signal 1
Signal Builder
Click Here
f(u)
1
s
1
s
Fcn
Integrator
Integrator1
Scope
Scope2
f(u)
1
s
1
s
Fcn1
Integrator2
Integrator3
Gain1
-K-
cart
K*u
pole
l
Gain
Scope1
MATLAB
Function
MATLAB Fcn
Terminator
10
12
Time (sec)
14
16
18
20
22