How to solve a second order linear differential equation with a heaviside function
조회 수: 16 (최근 30일)
이전 댓글 표시
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)
댓글 수: 0
답변 (1개)
Lateef Adewale Kareem
2017년 1월 23일
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)
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Calculus에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!