Solve system of differential equations with embedded non differential equation

1 visualización (últimos 30 días)
I have a system of 5 differential equations that I want to solve. The problem is that 2 of these equations contain a value alpha that depends on the solution of dX(1) and dX(3) as followed:
alpha=atan(X(3)/X(1));
As you can see this is not a differential equation, so my question is: How can I solve this problem, if my system of equations depends on alpha and alpha depends on the solution of these equations.
Alpha isn't implied in the attached code yet, because I don't know where and how.
Thanks for your help.
  3 comentarios
madhan ravi
madhan ravi el 5 de En. de 2019
There is an option to insert equations in latex form in the insert option.

Iniciar sesión para comentar.

Respuesta aceptada

madhan ravi
madhan ravi el 5 de En. de 2019
tSpan=[.01 30];
initial=[.01; .01; .01; .01; 68e3];%initial gues for x(0),ax(0),y(0),ay(0),m(0)and alpha(0)
^^^^^^^^^^^^^^^^^^^^^^^^---- only 5 conditions because you only have 5 equations
[t,x]=ode45(@fun,tSpan,initial);
x1=x(:,1);%first column of the x vector=Position in x direction
x2=x(:,2);%second column of the x vector=Acceleration in x direction
y1=x(:,3);%third column of the x vector=Position in y direction
y2=x(:,4);%fourth column of the x vector=Acceleration in y direction
m=x(:,5);%fifth column of the x vector= Mass
%plot overall position over time
postot=sqrt(x1.^2+y1.^2);%Phythagoras
figure
plot(t,postot)
xlabel('time[s]')
ylabel('vehicle position[m]')
title('vehicle position over time')
%plot overall acceleration overtime
acctot=sqrt(x2.^2+y2.^2);
figure
plot(t,acctot)
xlabel('time[s]')
ylabel('vehicle acceleration[m/s^2]')
title('Vehicle Acceleration over time')
function dX=fun(t,X)
%constants
g0=9.81;%[m/s^2]
Isp=390;%[s]
thrust=933910;%[N]
ceff=Isp*g0;
propflow=thrust/ceff;
%differential equations
alpha=atan(X(3)/X(1)); % have a look here
dX(1)=X(2);
dX(2)=(thrust*cos(alpha))/X(5);
dX(3)=X(4);
dX(4)=(thrust*sin(alpha))/X(5);
dX(5)=-propflow;
%Definition of dX
dX=[dX(1);dX(2);dX(3);dX(4);dX(5)];
end

Más respuestas (0)

Categorías

Más información sobre Ordinary Differential Equations 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