how to solve this differential equations with dsolve
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Furkan
am 23 Dez. 2016
Kommentiert: John BG
am 25 Dez. 2016
x'+2x+y=0
y'+x+2y=0
t=0 => x=1 , y=0
0 Kommentare
Akzeptierte Antwort
Star Strider
am 23 Dez. 2016
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 Kommentare
Weitere Antworten (1)
John BG
am 23 Dez. 2016
Bearbeitet: John BG
am 23 Dez. 2016
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 Kommentare
Siehe auch
Kategorien
Mehr zu Windows finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!