Solve numerically a system of first-order differential equations
31 ビュー (過去 30 日間)
古いコメントを表示
Hello everyone,
I have the following set of coupled first-order differential equations:
a*x'/z+y'=b;
x'/z-a*y'=c*sin(2*y);
z'=d*(e/z-(f+g*sin(2*y))*z);
where a, b, c, d, e, f, and g are some known parameters.
I was wondering which could be a good attempt to solve numerically this system of differential equations.
Any suggestion?
0 件のコメント
採用された回答
Star Strider
2020 年 3 月 31 日
Create the function symbolically:
syms a b c d e f g t x(t) y(t) z(t) T Y
Dx = diff(x);
Dy = diff(y);
Dz = diff(z);
Eqn1 = a*Dx/z+Dy == b;
Eqn2 = Dx/z-a*Dy == c*sin(2*y);
Eqn3 = Dz == d*(e/z-(f+g*sin(2*y))*z);
Eqn1s = simplify(lhs(Eqn1) - rhs(Eqn1), 'Steps', 100);
Eqn2s = simplify(lhs(Eqn2) - rhs(Eqn2), 'Steps', 100);
Eqn3s = simplify(lhs(Eqn3) - rhs(Eqn3), 'Steps', 100);
[VF,Subs] = odeToVectorField(Eqn1s, Eqn2s, Eqn3s);
odefcn = matlabFunction(VF, 'Vars',{T Y a b c d e f g});
producing (lightly edited):
odefcn = @(T,Y,a,b,c,d,e,f,g)[(Y(3).*(a.*b+c.*sin(Y(2).*2.0)))./(a.^2+1.0);(b-a.*c.*sin(Y(2).*2.0))./(a.^2+1.0);-(d.*(-e+f.*Y(3).^2+g.*sin(Y(2).*2.0).*Y(3).^2))./Y(3)];
Then use the solver of your choice to integrate it.
8 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Equation Solving についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!