How to solve a second order linear differential equation with a heaviside function

5 vues (au cours des 30 derniers jours)
I want to numerically solve the LDE (Linear Differential Equation) by integrating it numerically according to a flow diagram (see attached file). I have tried my best to come up with a script, but it does not give the correct answer.
clear all;
close all;
syms y(t) x(t) t
Dy = diff(y,t); D2y = diff(y,t,2); old = sympref ('HeavisideAtOrigin', 1);
cond = [y(0)==0, Dy(0)==0, D2y(0)==0];
eqn = diff(y,t,2) + 3*diff(y,t,1) + 2*y == heaviside(t);
ySol(t) = dsolve (eqn)

Réponses (1)

Lateef Adewale Kareem
Lateef Adewale Kareem le 23 Jan 2017
Since its a second order differential equation, there is no need for y''(0)
and since you want to solve numerically, you can try this
Dy = diff(y,t); D2y = diff(y,t,2); old = sympref ('HeavisideAtOrigin', 1);
cond = [0, 0];
eqn = @(t,y) [y(2); -3*y(2)-2*y(1) + heaviside(t)]; [T,Y] = ode45(eqn,[0,20],cond)
visualize
plot(T,Y)

Community Treasure Hunt

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

Start Hunting!

Translated by