apply laplace transform to a differential equation, it shows subs(diff(y(t), t), t, 0) instead of D(y)(0)

syms s t Y y(t)
dEqn=diff(y(t),t,2)+diff(y(t),t)+100*y(t)==400*dirac(t-3)
dEqn =
100*y(t) + diff(y(t), t) + diff(y(t), t, t) == 400*dirac(t - 3)
LdEqn=laplace(dEqn)
LdEqn =
s*laplace(y(t), t, s) - y(0) - s*y(0) + s^2*laplace(y(t), t, s) - subs(diff(y(t), t), t, 0) + 100*laplace(y(t), t, s) == 400*exp(-3*s)
I try to use laplace transforms to solve a differential euqation. Normally D(y)(0) can be replaced using subs() function. But the result is an equation with subs() and it can't be replaced using subs(). How to deal with it?

3 Comments

I am running into the same problem. Can you update this post if you figure it out?
MATLAB only does Laplace on first order differential equations. You will need to convert your equation to a first order. I did this by creating y = dx/dt and adding it to my equation.
% Reduce to first order
% Initiate variables: here y = dx/dt
syms s t x(t) y(t) X m b k P w
% Create equation of motion and take laplace
f1 = m*diff(y(t), t) + b*y + k*x == k*P*sin(w*t);
L1 = laplace(f1);
% Replace laplace terms
% For each derivative term you will need to multiply by another s
L1 = subs(L1, [laplace(x(t), t, s) laplace(y(t), t, s)], [X s*X+y(0)]);
% Replace IC's:
L1 = subs(L1, [x(0) y(0)], [0 0])
Matlab can handle 2nd and higher order differential equations
syms s t Y y(t)
dEqn=diff(y(t),t,2)+diff(y(t),t)+100*y(t)==400*dirac(t-3)
dEqn = 
LdEqn=laplace(dEqn)
LdEqn = 
To sub in a value for the initial condition of the derivative, first define
Dy(t) = diff(y(t),t);
then subs Dy(0) with its value, for example Dy(0) = 2
LdEqn = subs(LdEqn,[laplace(y(t)),y(0),Dy(0)],[Y,1,2])
LdEqn = 

Sign in to comment.

Answers (0)

Categories

Products

Asked:

on 28 Apr 2018

Commented:

on 12 Mar 2025

Community Treasure Hunt

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

Start Hunting!