Error using ode45. Must return a column vector?

Hi everyone!
I want to call ode45 like that:
[td, xp] = ode45(@diffeqns, [t, tfin], xp);
Where diffeqns is defined as:
function dxp = diffeqns(t,xp)
global GM
GM = 6.6742e-11 * 5.9736e24 * 10^-9 * 3600^2;
global Q
Q = [0 0 0 0; 0 0 0 0; 0 0 0.001 0; 0 0 0 0.001];
r = sqrt(xp(1)^2+xp(2)^2);
x = xp(1:4);
dx(1) = x(3);
dx(2) = x(4);
dx(3) = GM*x(1)/r^3;
dx(4) = GM*x(2)/r^3;
F = [0 0 1 0; 0 0 0 1; (GM*3*x(1)^2-r^2)/r^5 GM*3*x(1)*x(2)/r^5 0 0; ...
GM*3*x(1)*x(2)/r^5 GM*3*x(2)^2-r^2/r^5 0 0];
P = xp(5:20);
P = reshape(P,4,4);
dp = F*P+P*F'+Q;
dp = reshape(dp,1,16);
dxp = [dx dp];
end
dxp is a 1x20 vector, but I still get the error:
Error using odearguments (line 90)
DIFFEQNS must return a column vector.
Does anybody has any suggestion?
Thanks

 採用された回答

Stephan
Stephan 2019 年 1 月 14 日

0 投票

1x20 is not a column vector, but a row vector. transpose it to 20x1.

その他の回答 (0 件)

カテゴリ

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by