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

Okay.What have you tried so far, which problems occur and what is your question?

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

답변 (1개)

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

카테고리

제품

릴리스

R2018b

태그

질문:

2019년 2월 6일

답변:

2019년 2월 6일

Community Treasure Hunt

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

Start Hunting!

Translated by