second-order ODE, convert symbolic representation into matlabFunction

1 visualización (últimos 30 días)
Hi!
I my code a symbolic second order ODE is created. Because i want to solve the function with ode45 i transform the ODE into a system of first order ODEs.
All that works.
But: If the complexity an length of the ODE increases matlab takes a HUGE (up to hours) time to do "matlabFunction".
Here is the relevant part of my code([ ] is only explanation):
x = sym('x%d',[n,1]);
x = sym(x,'real');
xdot = sym('xdot%d',[n,1]); %
xdot = sym(xdot,'real');
xddot = sym('xddot%d',[n,1]); %
xddot = sym(xddot,'real');
[...some stuff happens here]
xddot=[f(x1,x2,x3,....,xdot1,xdot2,xdot3,...] %<- something like that
func=matlabFunction(xddot,'vars',{'t',[x;xdot]}); %<- slow!
any suggestions how to speed up things a little bit?
Greetings Alex

Respuestas (0)

Categorías

Más información sobre Symbolic Math Toolbox en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by