フィルターのクリア

Using dsolve to solve a system of differential equations analytically

1 回表示 (過去 30 日間)
Aleem Andrew
Aleem Andrew 2020 年 12 月 20 日
コメント済み: Star Strider 2020 年 12 月 21 日
When trying to solve a system analytically using dsolve, Matlab outputs that x is an empty function handle. Can someone explain why the following code does not work as expected?
m = 3.125*0.001; % Mass of the body in slug
Cd = 4.71*10^-7;
g = 32.2;
syms x(t) y(t)
Dx = diff(x,1);
D2x = diff(x,2);
Dy = diff(y,1);
D2y = diff(y,2);
[x,y] = dsolve([-Cd*Dx*sqrt(Dx^2+Dy^2)==m*D2x,-Cd*Dy*sqrt(Dx^2+Dy^2)-m*g==m*D2y],...
[x(0)==0 ,Dx(0)== 186*8.8/6*cosd(11.2), y(0) == 0, Dy(0)==186*8.8/6*sind(11.2)], 't');
x
x = matlabFunction(x)

採用された回答

Star Strider
Star Strider 2020 年 12 月 21 日
The differential equation system is nonlinear, so it likely does not have an analytic solution.
Try this instead:
m = 3.125*0.001; % Mass of the body in slug
Cd = 4.71*10^-7;
g = 32.2;
syms x(t) y(t) T Y
Dx = diff(x,1);
D2x = diff(x,2);
Dy = diff(y,1);
D2y = diff(y,2);
[VF,Sbs] = odeToVectorField([-Cd*Dx*sqrt(Dx^2+Dy^2)==m*D2x,-Cd*Dy*sqrt(Dx^2+Dy^2)-m*g==m*D2y],...
[x(0)==0 ,Dx(0)== 186*8.8/6*cosd(11.2), y(0) == 0, Dy(0)==186*8.8/6*sind(11.2)]);
Fcn = matlabFunction(VF, 'Vars',{T,Y});
[T,Y] = ode45(Fcn, [0 10], [0 0 0 1]);
figure
plot(T, Y)
grid
legend(string(Sbs), 'Location','SW')
.
  2 件のコメント
Aleem Andrew
Aleem Andrew 2020 年 12 月 21 日
Thanks for your help
Star Strider
Star Strider 2020 年 12 月 21 日
As always, my pleasure!

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by