second-order ODE, convert symbolic representation into matlabFunction

조회 수: 2 (최근 30일)
Alex
Alex 2012년 1월 19일
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개)

카테고리

Help CenterFile Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by