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

2 Ansichten (letzte 30 Tage)
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)

Antworten (1)

Lateef Adewale Kareem
Lateef Adewale Kareem am 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)

Kategorien

Mehr zu Particle & Nuclear Physics 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