필터 지우기
필터 지우기

Multi-input state space solution using ODE45

조회 수: 1 (최근 30일)
savvas
savvas 2015년 10월 6일
편집: savvas 2015년 10월 6일
I have the linear dynamics set up as follows:
function dx = sys(t,x)
global c m g r J
A = [0 0 0 1 0 0
0 0 0 0 1 0
0 0 0 0 0 1
0 0 -g -c/m 0 0
0 0 0 0 -c/m 0
0 0 0 0 0 0];
B = [0 0
0 0
0 0
1/m 0
0 1/m
r/J 0];
K = [-3.1623 0.0000 20.1673 -4.7754 0.0000 4.4257
0.0000 3.1623 0.0000 0.0000 5.8914 0.0000];
u = K*x;
dx = A*x + B*u;
end
And the call to the solution:
global c m g r J
m = 4;
J = 0.0475;
r = 0.055;
g = 9.8;
c = 0.05;
tspan = [0 10];
iniCon = [-1; -1; 0; 0; 0; 0; 0; 0];
[t,y] = ode45(@(t,x) sys(t,x),tspan,iniCon);
plot(t,y)
When I run the solution I get an error saying that the inner dimensions of u = K*x do not match. Does anyone know where the mistake is?
Thanks

채택된 답변

Torsten
Torsten 2015년 10월 6일
K is (2x6) and x is (8x1), thus K*x is not defined.
Best wishes
Torsten.
  댓글 수: 2
savvas
savvas 2015년 10월 6일
편집: savvas 2015년 10월 6일
I don't understand how x is defined. Can you elaborate?
Edit: Figured it out! Thanks a lot. The iniCon vector is defined wrong; (8x1) instead of (6x1).
Torsten
Torsten 2015년 10월 6일
iniCon = [-1; -1; 0; 0; 0; 0; 0; 0];
Best wishes
Torsten.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by