excelhelp
excelhelp

Reputation: 91

ode45 error, index out of bounds because numel(x)=1

    function xx = test(x, t)


   xx(1) = x(2);
   xx(2) = x(3) * cos(x(4) + x(1));
   xx(3) = 0;
   xx(4) = 0;

end

That is my script, confused as to why I am getting this error.

Upvotes: 0

Views: 181

Answers (1)

TroyHaskin
TroyHaskin

Reputation: 8401

The right-hand side given to the ODE suites pass the arguments as (t,x) where t is always scalar. So your function signature should be

function xx = test(t,x)

Upvotes: 3

Related Questions