# Solving non-linear ODE

4 views (last 30 days)
Advay Mansingka on 14 May 2021
Commented: Advay Mansingka on 14 May 2021
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 on 14 May 2021
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
Advay Mansingka on 14 May 2021
Thank you so much for your help sir!