Effacer les filtres
Effacer les filtres

Multi-input state space solution using ODE45

1 vue (au cours des 30 derniers jours)
savvas
savvas le 6 Oct 2015
Modifié(e) : savvas le 6 Oct 2015
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

Réponse acceptée

Torsten
Torsten le 6 Oct 2015
K is (2x6) and x is (8x1), thus K*x is not defined.
Best wishes
Torsten.
  2 commentaires
savvas
savvas le 6 Oct 2015
Modifié(e) : savvas le 6 Oct 2015
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 le 6 Oct 2015
iniCon = [-1; -1; 0; 0; 0; 0; 0; 0];
Best wishes
Torsten.

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by