Substitution of initial numerical values before odefunction

조회 수: 1 (최근 30일)
Tony Cheng
Tony Cheng 2019년 7월 17일
댓글: Torsten 2019년 7월 19일
Hi guys,
I am using ode45 to solve a system of ODEs. According to the syntax of ode45, the system is formatted into the form of
where x(t) is a 32*1 symbolic vector in our project whose elements are to be solved in ode45.
Then odefunction is applied to build the handle for mass matrix like
Mass_handle = odefunction( M( t, x(t) ) )
However, the size of M( t, x(t) ) is very huge and the elements inside it are really complicated, then it is quite time-consuming to return Mass_handle: by now it has taken over 96 hours and consumes over 45GB in RAM in our PC and it is still running at this moment.
Here I have an idea: since we have the initial numerical values of x(t), are we able to substitute the 32 symbolic variables in x(t) by their initial numerical values before running the code
Mass_handle = odefunction( M( t, x(t) ) )
Because we notice that in ode45, it is necessary to input the initial values of the symbolic variables, according to its syntax like ode45(odefun, tspan, y0), where y0 is the initial value vector.
If we substitute the initial numerical values of x(t) before running the code odefunction( M( t, x(t) ) ), then M( t, x(t) ) will be numerical rather than symbolic. It will just take a second to return Mass_handle.
Here we want to know: is this way feasible ? if not, are there any methods to deal with this problem?
Many thanks!
Cheers

채택된 답변

Torsten
Torsten 2019년 7월 17일
Use "matlabFunction" to convert every symbolic input to ODE45 into numerical function handles before calling ODE45.
  댓글 수: 2
Tony Cheng
Tony Cheng 2019년 7월 18일
Hi Torsten,
Thanks so much for your reply!
I guess what you mean is:
Firstly , Mass_handle = matlabFunction ( Mass_matrix( x ) ) is applied to generate a function handle;
Then, numerical values are input into Mass_handle to get a numerical matrix Mass_handle_numerical ;
Thirdly, Mass_handle_numerical is input into ode45.
Via these three steps, the symbolic Mass_matrix( x ) is now completely numerical in Mass_handle_numerical.
If these three steps are all right, I will implement these steps in the project.
Cheers
Torsten
Torsten 2019년 7월 19일
Yes, that's what I meant.
Before calling ode45 with the function handle, you should output the handle into a file to see the list of numerical parameters and the order in which they have to be supplied.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

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

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by