Filter löschen
Filter löschen

Solving differential equations involving heaviside function.

10 Ansichten (letzte 30 Tage)
Sayan Batabyal
Sayan Batabyal am 12 Dez. 2020
Beantwortet: Alan Stevens am 12 Dez. 2020
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.

Antworten (1)

Alan Stevens
Alan Stevens am 12 Dez. 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

Kategorien

Mehr zu Symbolic Math Toolbox finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by