필터 지우기
필터 지우기

Changing constant with timespan in ode45 solver

조회 수: 1 (최근 30일)
Koren Murphy
Koren Murphy 2020년 10월 15일
댓글: Bhanu Pratap Akherya 2021년 8월 18일
I am writing a code that solves a set of equations from ode45. However, I have a constant that changes in the equations at every time point. E.g.
dA = J(1)*x;
dB = J(5)*x;
So at t = 0, x =0 but at t = 1, x =0.25 etc. The solutions are then used as initial values for the next ode solver loop etc. How can I implement this so the ode can solve with this in mind?
I have tried for loops but still no luck.

채택된 답변

Alan Stevens
Alan Stevens 2020년 10월 15일
Make x a function of t and call it from the function defining the rate equations ode45 is calling..
  댓글 수: 15
Alan Stevens
Alan Stevens 2021년 8월 18일
You should make this a completely separate thread, in which you also upload the coding you have implemented so far.
Bhanu Pratap Akherya
Bhanu Pratap Akherya 2021년 8월 18일
Thanks for the reply alan, I have posted the question can you please help? Here is the link to the question: https://in.mathworks.com/matlabcentral/answers/1436182-changing-values-of-rhs-with-each-time-step-in-ode

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

추가 답변 (1개)

Ameer Hamza
Ameer Hamza 2020년 10월 15일
편집: Ameer Hamza 2020년 10월 15일
See this example on the documentation page of ode45(): https://www.mathworks.com/help/matlab/ref/ode45.html#bu3l43b. It shows how to deal with time-varying parameters.

카테고리

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

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by