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 CenterFile Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by