필터 지우기
필터 지우기

Second derivative of solution from ode45

조회 수: 1 (최근 30일)
e_frog
e_frog 2020년 11월 4일
댓글: e_frog 2020년 11월 5일
I have a system of 2 second order ODEs, which i converted to a system of fist order ODEs, which ode45 (or ode15s) needs as an input
my system input looks like this:
as an output i get the vector , but I need the derivatives and . How can i get those?
I tried using the gradient function as suggested by Star Strider in this question: How to output derivative from ODE 45 but unfortunately that did not help.
Thanks in advance!

채택된 답변

Bjorn Gustavsson
Bjorn Gustavsson 2020년 11월 4일
편집: Bjorn Gustavsson 2020년 11월 4일
After integrating your ODE-system you will have for some , and you have the function for your ODE-equations, f(t,X), one way to calculate the accelerations at times will be to simply call:
dxd2xdyd2ydt(i,:) = f(t_i,X(i,:));
Typically I use a regularly space array for the time in the call to ode45 and use the gradient-function, but the above should work - that is after all what we expect odeNN: to give us a solution X where that is true...
HTH
  댓글 수: 8
James Tursa
James Tursa 2020년 11월 4일
편집: James Tursa 2020년 11월 4일
If the ode_exo_ho( ) function is vectorized (meaning it will accept vectors and properly calculate a vector result), then yes it is just this easy. If ode_exo_ho( ) is not vectorized, then you would have to call it in a loop, but still pretty easy.
The ease of vectorizing your function depends on what it is doing. Sometimes it is just a simple matter of replacing the operators * and / and ^ with their element-wise counterparts .* and ./ and .^
e_frog
e_frog 2020년 11월 5일
ty it worked!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by