how to solve this differential equations with dsolve
조회 수: 1 (최근 30일)
이전 댓글 표시
x'+2x+y=0
y'+x+2y=0
t=0 => x=1 , y=0
댓글 수: 0
채택된 답변
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
추가 답변 (1개)
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
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Windows에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!