solving coupled differential equations

15 ビュー (過去 30 日間)
MAMTA SINGH
MAMTA SINGH 2019 年 6 月 1 日
回答済み: Bjorn Gustavsson 2019 年 6 月 1 日
I have three equations, two are first order and one is second order. Kindly suggest the code to solve it. I have attached my equations in attachment.
Thanks

採用された回答

Bjorn Gustavsson
Bjorn Gustavsson 2019 年 6 月 1 日
For symbolic solutions look at the help for dsolve, for numerical soutions convert the 2nd order ode to 2 coupled first-order odes, then put all 4 first-order ODEs into one function and one of the odeNN (ode45, ode23, etc) with that function, the time-spand and your initial condition. Something like this would be the ODE-function:
function dydt = your_ode(t,y)
w_m = 21; % and so on for your other constants - you could also have them as additional inputs
w1 = y(1);
w2 = y(2);
f = y(3);
dfdt = y(4);
dw1dt = (w_m - y(3))*exp(f-12t);
dw2dt = (w1 - w2*sin(12*t));
d2fdt2 = f+12*w1-w2; % change to your actual ODEs here...
dydt = [dw1dt;dw2dt;dfdt;d2fdt2];
end
Then call, for example, ode45:
w1_0 = 123;
w2_0 = 231;
f_0 = exp(pi);
dfdt_0 = sqrt(2);
y0 = [w1_0;w1_0;f_0;dfdf_0];
t = [0,37];
[T,w1w2fdfdt] = ode45(@(t,y) your_ode(t,y),t,y0);
HTH

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeNumeric Solvers についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by