필터 지우기
필터 지우기

LaPlace Transform with initial conditions

조회 수: 66 (최근 30일)
Kyle Langford
Kyle Langford 2022년 3월 27일
편집: Paul 2022년 3월 29일
I am having a hard time using MATLAB to solve LaPlace transforms.
I need to solve
I don't really understand how to write the derivatives in MATLAB, or set the initial conditions using built ins. Or are there built ins?
2022a

채택된 답변

Star Strider
Star Strider 2022년 3월 27일
The procedure is not exactly straightforward, so I will demonstrate a working approach —
syms s t y(t) Y(s)
D1y = diff(y);
D2y = diff(D1y);
Eqn = D2y + 7*D1y + 12*y == 14*heaviside(2)
Eqn(t) = 
LEqn = laplace(Eqn)
LEqn = 
LEqn = subs(LEqn, {laplace(y(t),t,s), y(0), D1y(0)}, {Y(s), 2, 0})
LEqn = 
LEqn = isolate(LEqn, Y(s))
LEqn = 
y(t) = ilaplace(rhs(LEqn))
y(t) = 
figure
fplot(y, [0 2.5])
grid
Experiment with my code to understand how it works.
.
  댓글 수: 12
Star Strider
Star Strider 2022년 3월 29일
Thank you!
It’s much more useful now than when it was introduced.
Paul
Paul 2022년 3월 29일
편집: Paul 2022년 3월 29일
The posted solution in this comment is a peculiar approach. The first equation for Y(s) seems o.k. with the u(t) = 2 being expressed more formally as u(t) = 2*heaviside(t) and U(s) = 2/s, which is why we see the 2 in the numerator and s in the denominator on the first term on the RHS. But in the next step it looks like the 2 in the numerator is replaced with a symbolic constant, also called u (with the expectation that eventually u will be replaced with 2 as stated in the parenthetical). So in the end, the posted solution is the response of the system with the initial conditions y(0) = y0, ydot(0) = 0, and input u(t) = u*heaviside(t).
syms s
syms t y0 real
syms y(t) Y(s) u(t) U(s)
d1y=diff(y);
d2y=diff(d1y);
eq1=d2y+7*d1y+12*y==14*u(t)
eq1(t) = 
Leq1=laplace(eq1);
Leq1=subs(Leq1,{laplace(y(t),t,s),y(0),d1y(0), laplace(u(t),t,s)},{Y(s),y0,0,U(s)})
Leq1 = 
Leq1=isolate(Leq1,Y(s))
Leq1 = 
syms u real % reusing the same variable name, unfortunately
Leq1 = subs(Leq1,U(s),laplace(u*heaviside(t)))
Leq1 = 
Leq1 = partfrac(Leq1,s) % same as shown in the posted solution
Leq1 = 
y(t) = ilaplace(rhs(Leq1))
y(t) = 
Which is the same as the posted solution. I would write it as
y(t) = ilaplace(rhs(Leq1))*heaviside(t)
y(t) = 
The steps in the posted solution are very strange, IMO, to first use the explicit expression u(t) = 2*heaviside(t), based on the problem statement, and then subsequently switch to the general u(t) = u*heaviside(t), all the while only ever using the symbolic constant for the initial condition.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Calculus에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by