Add initial conditions when using laplace function
9 views (last 30 days)
Show older comments
I want to add the initial conditions x1(0) = 0, x2(0) = 0, diff(x1,t)|0 = 0 and diff(x2,0)|0 = 0 to the laplace transform lap1 and lap2.
syms M2 K2 B2 x2(t) M1 B1 x1(t) f(t)
%considering mass M1 only
eqn1 = M1 * diff(x1,t,2) + B1 * diff(x1,t) + B2*(diff(x1,t) - diff(x2,t)) == f(t);
%considering mass M2 only
eqn2 = M2 * diff(x2,t,2) + B2*(diff(x2,t) - diff(x1,t)) == 0;
Taking laplace of both equation
lap1 = laplace(eqn1)
lap2 = laplace(eqn2)
0 Comments
Accepted Answer
Star Strider
on 6 Nov 2023
Edited: Star Strider
on 6 Nov 2023
That requires a subs call for each equation. (The sympref call here makes this easier. You can remove it later if desired.)
Try this —
syms M2 K2 B2 x2(t) M1 B1 x1(t) f(t)
sympref('AbbreviateOutput',false); % Optional
%considering mass M1 only
eqn1 = M1 * diff(x1,t,2) + B1 * diff(x1,t) + B2*(diff(x1,t) - diff(x2,t)) == f(t);
%considering mass M2 only
eqn2 = M2 * diff(x2,t,2) + B2*(diff(x2,t) - diff(x1,t)) == 0;
lap1 = laplace(eqn1)
lap1 = subs(lap1, {x1(0), x2(0), subs(diff(x1(t), t), t, 0), subs(diff(x2(t), t), t, 0)}, {0, 0, 0, 0})
lap2 = laplace(eqn2)
lap2 = subs(lap2, {x1(0), x2(0), subs(diff(x1(t), t), t, 0), subs(diff(x2(t), t), t, 0)}, {0, 0, 0, 0})
A while ago, I requested that something similar to the dsolve initial conditions be made part of the laplace call. So far, no changes.
EDIT — Æsthetic improvements.
.
0 Comments
More Answers (0)
See Also
Categories
Find more on Particle & Nuclear Physics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!