second-order ODE, convert symbolic representation into matlabFunction

3 Ansichten (letzte 30 Tage)
Alex
Alex am 19 Jan. 2012
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

Antworten (0)

Kategorien

Mehr zu Symbolic Math Toolbox finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by