how to solve this differential equations with dsolve

2 ビュー (過去 30 日間)
Furkan
Furkan 2016 年 12 月 23 日
コメント済み: John BG 2016 年 12 月 25 日
x'+2x+y=0
y'+x+2y=0
t=0 => x=1 , y=0

採用された回答

Star Strider
Star Strider 2016 年 12 月 23 日
It is straightforward to incorporate the initial conditions in the dsolve call:
syms x(t) y(t)
Dx = diff(x);
Dy = diff(y);
[x,y] = dsolve(Dx + 2*x + y == 0, Dy + x + 2*y == 0, x(0) == 1, y(0) == 0)
x =
exp(-t)/2 + exp(-3*t)/2
y =
exp(-3*t)/2 - exp(-t)/2
  5 件のコメント
Furkan
Furkan 2016 年 12 月 23 日
Thanks Mr. John BG but first part of answer already enough for me, ı dont need more details at this problem.But both of answers are correct and usefull thanks . Best regards.
John BG
John BG 2016 年 12 月 25 日
it's ok, thanks for reading my answer

サインインしてコメントする。

その他の回答 (1 件)

John BG
John BG 2016 年 12 月 23 日
編集済み: John BG 2016 年 12 月 23 日
1.
solving the system
syms x(t) y(t)
z=dsolve(diff(x)==-y-2*y,diff(y)==-x-2*y)
z.x
=
C2*exp(-3*t) - 3*C1*exp(t)
z.y
=
C1*exp(t) + C2*exp(-3*t)
2.
applying initial conditions, A(t=0):
A=[1 -3;1 1]
b=[1;0]
s=A\b
=
0.250000000000000
-0.250000000000000
C1=s(1)
C1 =
0.250000000000000
C2=s(2)
C2 =
-0.250000000000000
3. Build real functions
fx=matlabFunction(z.x)
fx =
@(C1,C2,t)C1.*exp(t).*-3.0+C2.*exp(t.*-3.0)
fy=matlabFunction(z.y)
fy =
@(C1,C2,t)C1.*exp(t)+C2.*exp(t.*-3.0)
t=[10:.1:10]
fx(C1,C2,t)
=
-1.651984934610504e+04
fy(C1,C2,t)
=
5.506616448701680e+03
if you find these lines useful would you please mark my answer as Accepted Answer?
To any other reader, please if you find this answer of any help, click on the thumbs-up vote link,
thanks in advance for time and attention
John BG

カテゴリ

Help Center および File ExchangeWindows についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by