MATLAB: Solving second order differential equations with LaPlace Transforms: getting an error when trying to input an initial condition (R2017b) (“error: untitled line”)

buglaplacelaplace transform

This is my code. I am getting an error in
syms s
eqn=sym('D(D(y))(t)+D(y)(t)+y(t)=((t+1)^3)*exp(-t)*cos(t)*sin(3*t)');
lteqn=laplace(eqn,t,s)
syms y ;
neweqn=subs(lteqn,{'laplace(y(t),t,s)','y(0)',''D(y)(0)'},{Y,1,0})
% the line above has the error, and the issue is with the 'D(y)(0)' term
ytrans=simplify(solve(neweqn,Y))
y=ilaplace(ytrans,s,t)

Best Answer

The laplace function does not accept initial conditions (as dsolve does).
I requested this as an enhancement several months ago. It has thus far not appeared.
You will have to do coding gymnastics with the subs function to do the necessary substitutions.
Related Question