Have you looked at the contents of DE_19.m
? You should provide the code you used before calling matlabFunction
, but here's a runnable version that might be something like what you used:
syms a16 x16;
DE_19 = matlabFunction([a16;-((1+x16^2)/(2*x16))*a16],'vars',{x16,[a16]})
This returns:
DE_19 =
@(x16,a16)[a16;(a16.*(x16.^2+1.0).*(-1.0./2.0))./x16]
As you can see, if you pass in a scalar state (the second argument, a16
, is the state and the first, x16
is the independent variable – this is true for all ODE solvers: t
then y
), the output will always two elements. And indeed the output will always be twice as long as the input state. Maybe a16
and x16
should be switched? Look at the help and documentation for matlabFunction
as they provide an example that does exactly this.
By the way, there's no real need to create a file. You can use the anonymous function returned by matlabFunction
like this (you'll need to figure out which variable is which and what is missing to still get it to work):
DE_19 = matlabFunction([...],'vars',{...})
[x,y] = ode45(DE_19,[1,11],[2,7,5]);