Using dsolve to solve a system of differential equations analytically

4 visualizaciones (últimos 30 días)
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)

Respuesta aceptada

Star Strider
Star Strider el 21 de Dic. de 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')
.

Más respuestas (0)

Categorías

Más información sobre Mathematics en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by