Solving non-linear ODE

1 visualización (últimos 30 días)
Advay Mansingka
Advay Mansingka el 14 de Mayo de 2021
Comentada: Advay Mansingka el 14 de Mayo de 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!

Respuesta aceptada

Walter Roberson
Walter Roberson el 14 de Mayo de 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
  1 comentario
Advay Mansingka
Advay Mansingka el 14 de Mayo de 2021
Thank you so much for your help sir!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Ordinary Differential Equations en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by