solving 2nd order nonlinear ode Numeric solution by using ode45
3 ビュー (過去 30 日間)
古いコメントを表示
the eqution
d^2u/dt -k(1-u^2)du/dt+au = 0
initial condition
u(0)=2 (dimensionless); du/dt (0)=0
question
(a) With 𝑘𝑘 = 1.0 s-1, determine the value of 𝑎𝑎 that would give a heart rate of 1.25 beats/second and Graphically display 𝑢𝑢(t) for this value of 𝑎𝑎 and 0 ≤ t≤ 5 𝑠𝑠 . (25 points).
(b) Graphically display 𝑢𝑢(t) for your chosen values 𝑘𝑘 and 𝑎𝑎 and 0 ≤ t ≤ 5 𝑠𝑠 . Interpret the results.
0 件のコメント
採用された回答
Alan Stevens
2020 年 10 月 4 日
This is the basic structure for solving the ode.
u0 = 2;
v0 = 0;
tspan = [0 5];
k = 1;
a = 25;
[t,U] = ode45(@odefn, tspan, [u0 v0],[],k,a);
u = U(:,1);
v = U(:,2);
plot(t,u),grid
xlabel('t'),ylabel('u')
function dUdt = odefn(~,U,k,a)
u = U(1);
v = U(2); % v = du/dt
dvdt = k*(1-u^2)*v - a*u;
dUdt = [v;
dvdt];
end
You could investigate fzero to get the value of k that gives 1.25 beats/sec, or adjust it manually (as I did here to get an approximate value).
4 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Ordinary Differential Equations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!