second-order ODE, convert symbolic representation into matlabFunction
1 view (last 30 days)
Show older comments
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
0 Comments
Answers (0)
See Also
Categories
Find more on Symbolic Math Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!