solve differential equation that have a time variant function and terms ode45
이전 댓글 표시
as the quistion says
i want to solve a diffrential equation that has the following form using ode45
where
a and b are constant
c(t) is a time deppendant term
f(x(t)) is a time deppendant function of x
g(t) is a time deppendant function
thank you.
댓글 수: 1
Jan
2019년 2월 6일
Okay.What have you tried so far, which problems occur and what is your question?
답변 (1개)
Bjorn Gustavsson
2019년 2월 6일
That should be just what the odeNN-suite of functions are made for. Just write yourself a function where you express the 2nd order ODE as 2 coupled 1st-order:
function dxdt = myode(t,x)
a = % whatever values you have for your coefficients
b = % same difference
c = c_of_t(t);
f = f_of_x(t,x);
g = g_of_t(t);
dxdt = [x(2);
1/a*(g - b*x(2) - c*f)];
end
Where c_of_t f_of_t and g_of_t are whatever functions you need to call/define. Then simply call ode45 as in the documentation example.
HTH
카테고리
도움말 센터 및 File Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!