![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/298033/image.png)
How to solve ODE in which one variable depends on precedents variable states
조회 수: 2 (최근 30일)
이전 댓글 표시
Hi,
I would like to solve this equation
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/297993/image.png)
That is a 2nd order differential equation for a single degree of freedom oscillator.
I am using ode45 but the problem is to compute the restoring force
. If the current time is denoted as t and the time step as
, one has
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/297998/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/298003/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/298008/image.png)
Therefore, I need to store precedents variable states to compute
and consequently to solve ODE. I read there is a possibility to use global variables and to have access to current time values utilized the option Output function. However, I'm not exactly sure how to use the Output function and, unfortunately, I didn't find any examples in which it was clear how to use it. Is there anyone that can share an example that suits me? I would like to specify I pass the interval of integration as a vector with two elements, namely the initial and final times.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/298013/image.png)
Kind regards
Califfo
댓글 수: 2
답변 (1개)
Steven Lord
2020년 5월 22일
It sounds like you don't have an ordinary differential equation (ODE) but a delay differential equation (DDE.)
참고 항목
카테고리
Help Center 및 File Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!