solve differential equation that have a time variant function and terms ode45
3 views (last 30 days)
Show older comments
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 Comment
Answers (1)
Bjorn Gustavsson
on 6 Feb 2019
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
0 Comments
See Also
Categories
Find more on Ordinary Differential Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!