Solving non-linear ODE

1 回表示 (過去 30 日間)
Advay Mansingka
Advay Mansingka 2021 年 5 月 14 日
コメント済み: Advay Mansingka 2021 年 5 月 14 日
I am trying to solve the following differential equation:
The code I am using is:
function EP_equation
syms y(t)
time_range = [0 5];
init_vals = 0.01;
[t, y] = ode45(@(t,y) simple_ode(t,y), time_range, init_vals);
figure
plot(t,y, 'LineWidth', 2)
xlim(time_range)
end
function dRdt = simple_ode(t,R)
dRdt = (1/R + 1/t^0.5);
end
However I am unable to get an answer. Please do let me know if there are things I can do to fix this, or obvious flaws in the code.
Thank you!

採用された回答

Walter Roberson
Walter Roberson 2021 年 5 月 14 日
Your equation has 1/sqrt(t) and initial t of 0. That gives you 1/sqrt(0) -> 1/0 -> infinity at the start
EP_equation
ans = 1×2
0.0000 5.0000
Name Size Bytes Class Attributes y 1021x1 8168 double
ans = 1×2
0.0100 6.1108
function EP_equation
syms y(t)
time_range = [eps(realmin) 5];
init_vals = 0.01;
[t, y] = ode45(@(t,y) simple_ode(t,y), time_range, init_vals);
figure
plot(t,y, 'LineWidth', 2)
xlim(time_range)
[min(t), max(t)]
whos y
[min(y), max(y)]
end
function dRdt = simple_ode(t,R)
dRdt = (1/R + 1/t^0.5);
end
  1 件のコメント
Advay Mansingka
Advay Mansingka 2021 年 5 月 14 日
Thank you so much for your help sir!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeOrdinary Differential Equations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by