LaPlace Transform with initial conditions
現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
古いコメントを表示
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
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 件のコメント
Paul
2022 年 3 月 27 日
Shoud the RHS of Eqn be: 14*2*heavisde(t)?
Walter Roberson
2022 年 3 月 27 日
The u function involved is some constant function, not heaviside. The initial conditions say that u(t)=2 not u(0)=2. Heaviside does not have a strict definition at 0, with u(0)=0 and u(0)=1 and u(0)=1/2 all having their uses, so it would be pretty unusual but not strictly wrong to say u(0)=2. But we are not told u(0)=2, we are told u(t)=2, which includes u(-1) and u(0) and u(1) all = 2. Not heaviside.
The problem statement says that "u(t) = 2." The problem statement also says to solve the equation via the Laplace transform, which typically is the one-sided transform, and certainly is in Matlab's laplace() function, which implies the input is zero for t < 0-. All in all within the context of the problem statement, I'd say it's safe to assume that the statement "u(t) = 2" really means u(t) = 2*heavisde(t). Only the OP will know for sure.
Kyle Langford
2022 年 3 月 28 日
You guys are awesome. I haven't played any laplace stuff in MATLAB like heaviside or laplace/ilaplace. I am still a little shakey on how to correctly use subs, especially when subbing multiple things.
I need to do some more MATLAB classes haha.
I kept trying it by making an equation with a @(t) handle, which was not working.
This is extremely helpful. Though, I am not 100% confident I could repeat this on my own, I will play with this and apply it to some other problems.
Would this be an acceptable way of solving this? By not using heaviside?
I know this is more of a math question vs MATLAB.
clear;clc;
disp('Problem 1')
Problem 1
syms s t y(t) Y(s) u(t) U(s)
d1y=diff(y);
d2y=diff(d1y);
eq1=d2y+7*d1y+12*y==14*u
eq1(t) =

Leq1=laplace(eq1)
Leq1 =

Leq1=subs(Leq1,{laplace(y(t),t,s),y(0),d1y(0), laplace(u(t),t,s)},{Y(s),2,0,2})
Leq1 = 
Leq1=isolate(Leq1,Y(s))
Leq1 =
y(t)=ilaplace(rhs(Leq1))
y(t) = 
fplot(y,[0 2.5])
grid on

Star Strider
2022 年 3 月 28 日
Yes!
(I usually interpret
as the unit step or Heaviside function, however here that appears not to be correct.)
.
Paul
2022 年 3 月 28 日
What is the justification for the substitution U(s) = 2?
Kyle Langford
2022 年 3 月 29 日
@Paul I guess you are right. u(t)=2, not U(s)=2
This seems to be the (or a) solution to this problem.
I have been trying to maniupulate MATLAB to give a similar solution, but I cannot get there.

The original Laplace transform:
does not appear to contain u.
I don’t understand where it came from.
If it’s just a constant:
syms s t u y(t) Y(s)
D1y = diff(y);
D2y = diff(D1y);
Eqn = D2y + 7*D1y + 12*y == 14*2*u;
LEqn = laplace(Eqn);
LEqn = subs(LEqn, {laplace(y(t),t,s), y(0), D1y(0)}, {Y(s), 2, 0});
LEqn = isolate(LEqn, Y(s))
LEqn =

y(t) = ilaplace(rhs(LEqn))
y(t) =

y(t) = expand(y(t))
y(t) =
That’s likely as close as it’s possible to get to the intended result.
.
Kyle Langford
2022 年 3 月 29 日
Looks good enough to me. I appreciate the knowledge of laplace in MATLAB!
Star Strider
2022 年 3 月 29 日
Thank you!
It’s much more useful now than when it was introduced.
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 件)
カテゴリ
ヘルプ センター および File Exchange で Symbolic Math Toolbox についてさらに検索
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
