Solving differential equations involving heaviside function.
6 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (1)
Alan Stevens
le 12 Déc 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 commentaires
Voir également
Catégories
En savoir plus sur Ordinary Differential Equations dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!