필터 지우기
필터 지우기

Order of the Matlab Ode Solutions Appearing at Output?

조회 수: 1 (최근 30일)
S H
S H 2019년 1월 11일
댓글: Steven Lord 2019년 1월 14일
When solving higher order differential equations using an ode solver (for example [t,y]=ode15i...), there are many outputs in y such as v1(t), v2(t), v3(t), Dv2t(t), Dv3t(t), Dv4t(t).
How do these signals appear at output (y) of the ode solver? What is their order?
In other words, what should I expect to get at y(:,1), y(:,2),...,y(:,end)?

채택된 답변

Stephan
Stephan 2019년 1월 11일
편집: Stephan 2019년 1월 11일
Hi,
unfortunally Matlab sometimes changes the order of outputs to an order which appears not be logical (at least for me). I dont know why this happens, but it does in some cases. For ODE's it is a good idea to call odeToVectorField with two output arguments like shown here. The order of new_vars is corresponding to the output arguments of y, if you use matlabFunction to create the function handle.
In case of DAE the usage of reduceDAEIndex needs two output arguments which are new_eqs and new_vars. The usage of daeFunction needs both inputs, so that i would expect the order of the input vector for new_vars as the order of the output. But to be honest, for DAE i have no experiences.
Best regards
Stephan
  댓글 수: 1
S H
S H 2019년 1월 13일
I had the same observation that each ode sometimes generate results with different orders. Thank you for clearing my doubts.

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

추가 답변 (1개)

Steven Lord
Steven Lord 2019년 1월 13일
If you're solving ODEs using ode15i or any of the numeric ODE solvers in MATLAB, the order of the solutions in the y output (or the y field of the sol output) should not change. They should be in the same order as the input y that the ODE solver passes into your ODE function.
If you're solving ODEs using dsolve from Symbolic Math Toolbox, see the "Assign Outputs to Functions or Variables" section of the documentation page for dsolve. In this case I recommend calling dsolve with one output and retrieving the solutions from the appropriate fields of that struct array. This avoids needing to worry about the order in which symvar orders the variables.
  댓글 수: 2
S H
S H 2019년 1월 14일
Hummm...okay I will check my codes again. Thanks.
Steven Lord
Steven Lord 2019년 1월 14일
If you see this type of behavior from the numeric ODE solvers, please either show a small section of code that demonstrates the behavior or send such a section of code to Technical Support using the Contact Us link in the upper-right corner of this page.

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

카테고리

Help CenterFile Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by