Laplace Transform of Given Differential Equation

Hello, I have the differential equation with initial condtions: y'' + 2y' + y = 0, y(-1) = 0, y'(0) = 0.
I need to use MATLAB to find the need Laplace transforms and inverse Laplace transforms.
I'm not sure if what I have so far is correct, here is what I have...
syms s t Y;
f = 0;
F = laplace(f,t,s);
Y1 = s*Y - 0;
Y2 = s*Y1 - 0;
laplaceSol = solve(Y2 + 2*Y1 + Y - F, Y) %Laplace Transform
invlaplaceSol = ilaplace(laplaceSol,s,t) %Inverse Laplace Transform
I get the following as output.
laplaceSol = 0
invlaplaceSol = 0
I also have the following code in an m-file.
function myplot(f,interv)
% myplot(f,[a,b])
% plot f for interval [a,b]
% here f is a symbolic expression, or a string
%
% example:
% myplot('x^2',[-1,1])
% syms x; myplot(x^2,[-1,1])
f = sym(f);
tv = linspace(interv(1),interv(2),300);
T = findsym(f,1);
plot(tv,double(subs(f,T,tv)))
Thank you,

4 Commenti

Are you sure about that initial condiion y(-1) = 0? For these types of problems, intiial conditions are typically specified at t = 0, more specifically at t = 0-, i.e., an infinitesimal to the left of 0. I'm not even sure that a condition at t = -1 can be incorporated into the Laplace trasnsform approach at all.
Having said that, the solution y(t) = 0 does satisfy the differential equation and the initial conditions.
I double checked and yes y(-1) = 0 is one of the initial condtions.
MD.AL-AMIN
MD.AL-AMIN il 2 Mar 2024
Spostato: Sam Chak il 3 Mar 2024
y''(t) + 4y'(t) + 8y(t) = x' (t)+x(t) with x(t) = e ^ (- 4t) * u(t) y(0) = 0 and y'(0) = 0 matlab code
MD.AL-AMIN
MD.AL-AMIN il 2 Mar 2024
Spostato: Sam Chak il 3 Mar 2024
I don't know how to solve by using MATLAB?

Accedi per commentare.

Risposte (2)

Laplace transform does not work at t ~0 initial conditions and thus, here dsolve() might be a better option, e.g.:
syms y(t)
Dy=diff(y,t);
D2y = diff(y,t,2);
Eqn = D2y == -2*Dy-y;
ICs = [y(-1)==0, Dy(0)==0];
S = dsolve(Eqn, ICs)
S = 

7 Commenti

Interestingly, the Dy(0)==0 does not add any information -- if you solve for just the first IC then you get the same result.
For this task I need to specifically solve using Laplace and Inverse Laplace Transforms.
Then you will have to fail the assignment. Laplace transform is not valid for negative time.
I agree. Having said that, if both initial conditions were given at t = -1, then a solution via Laplace transform could be obtained by shifting the time variable (I think).
BTW, didn't this exact differential equation show up here no too long ago?
Yes, I have an assignment using this differential equation in MATLAB.
With this being my first time using MATLAB I have been needing a lot of assistance.
Though, considering that dsolve() using Dy(0) == 0 gives the same solution as dsolve() with y(-1)==0, then you could potentially ignore the y(-1) and go ahead with laplace.
I'm not sure how to include the initial conditions when using the laplace() function.

Accedi per commentare.

Note that if your system has "zero" ICs and not excitation force; therefore, your system solution (response) will be zero. If you set one of your ICs, non-zero varlue and then you'll see something, e.g.:
syms s Y t
y0=0;
dy0=-1; %
Y1 = s*Y - y0;
Y2 = s*Y1- dy0;
Sol = solve(Y2 + 2*Y1 + Y, Y)
Sol = 
Sol = ilaplace(Sol,s,t)
Sol = 
fplot(Sol, [-1, 1])
% Verify: alternative solution with dsolve() gives the same result
syms y(t)
Dy=diff(y,t);
D2y = diff(y,t,2);
Eqn = D2y == -2*Dy-y;
ICs = [y(0)==0, Dy(0)==-1];
S = dsolve(Eqn, ICs);
fplot(S, [-1, 1])

1 Commento

However... the posters have been clear that they have an initial condition at y(-1) not an initial condition at y(0) . Which is a problem for laplace transforms.

Accedi per commentare.

Categorie

Scopri di più su Mathematics in Centro assistenza e File Exchange

Prodotti

Release

R2022a

Richiesto:

il 25 Apr 2022

Spostato:

il 3 Mar 2024

Community Treasure Hunt

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

Start Hunting!

Translated by