Solving differential equations involving heaviside function.
15 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I have a set of differential equations involving heaviside function. I want to solve it numerically using ode45, however on solving I get all values of y as NaN. But the the derivative functions are not NaN. I think something is going wrong inside ode45. Can anyone guide on how to solve ODEs involving heaviside function using ode45? Please give suitable code snippets if possible.
0 comentarios
Respuestas (1)
Alan Stevens
el 12 de Dic. de 2020
Here's a snippet that works, but it would be better if you uploaded your code, as we stand a better chance of solving your problem that way:
tspan = [0 2];
ic = 1;
[t, y] = ode45(@fn, tspan, ic);
plot(t,y),grid
function dydt = fn(t,y)
u = heaviside(t-1);
dydt = -u*y;
end
0 comentarios
Ver también
Categorías
Más información sobre Symbolic Math Toolbox 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!