Filter löschen
Filter löschen

Using dsolve to solve a system of differential equations analytically

1 Ansicht (letzte 30 Tage)
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)

Akzeptierte Antwort

Star Strider
Star Strider am 21 Dez. 2020
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')
.

Weitere Antworten (0)

Kategorien

Mehr zu Mathematics 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!

Translated by