フィルターのクリア

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 Center および File ExchangeOrdinary Differential Equations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by