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
Jan 2019 年 2 月 6 日
Okay.What have you tried so far, which problems occur and what is your question?

サインインしてコメントする。

回答 (1 件)

Bjorn Gustavsson
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

カテゴリ

製品

リリース

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