Solving non-linear ODE

조회 수: 5(최근 30일)
댓글: 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 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표시숨기기 없음
Thank you so much for your help sir!

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

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

Start Hunting!

Translated by