I don't understand what is going wrong with my code!!, I get error of a matrix singular

function dy = rocketequat( t,y )
%UNTITLED6 Summary of this function goes here
g=9.81; % constant of gravity m/s^2
Ve=2800;%celerity of inject gas m/s
m0=500000;%initial mass =500000kg
dmdt=-2300;%kg/s
dy(1)= -g*sin(y(2)) - Ve * dmdt/( m0 - dmdt*t );%dy(1)=dvdt acceleration
dy(2)= ( g/y(1) )*cos( y(2) ); %dy(2)=dbetadt variation in angle of inclination
end
%in a script i wrote
[t,y]=ode23s(@rocketequat,[0 160],[0 pi/2]);
% i gut this message:
In rocket (line 1)
Warning: Matrix is singular, close to singular or badly scaled. Results may be inaccurate. RCOND = NaN.

Respuestas (1)

Stephan
Stephan el 30 de Dic. de 2018
Editada: Stephan el 30 de Dic. de 2018
Hi,
you do a divide by zero at the initial point - use another x0 for y(1) - for example try:
[t,y]=ode45(@rocketequat,[0 160],[0.0001 pi/2]);
plot(t,y(:,1),t,y(:,2))
function dy = rocketequat(t,y)
%UNTITLED6 Summary of this function goes here
g=9.81; % constant of gravity m/s^2
Ve=2800;%celerity of inject gas m/s
m0=500000;%initial mass =500000kg
dmdt=-2300;%kg/s
dy(1)= -g.*sin(y(2)) - Ve .* dmdt./( m0 - dmdt*t );%dy(1)=dvdt acceleration
dy(2)= ( g./y(1) ).*cos( y(2) ); %dy(2)=dbetadt variation in angle of inclination
dy=dy';
end
gives:
There is also no need for the useage of a stiff solver - ode45 will do the job.
Best regards
Stephan

7 comentarios

i think this is not the resultats that i wanted hhh
anyway .thanks m.stephen .
Stephan
Stephan el 30 de Dic. de 2018
Editada: Stephan el 30 de Dic. de 2018
i think, then there is an issue in your equations. Your question was why you get this warnings/errors - that is what i answered to. I did not change your equations - so this is not part of my answer, due to it is not part of your question.
you re right ;dy(1) should be egal to :
-g.*sin(y(2)) + Ve .* dmdt./( m0 - dmdt*t )
You are happy now?
thinks for your efforts m.stephen

Iniciar sesión para comentar.

Categorías

Más información sobre Particle & Nuclear Physics en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 30 de Dic. de 2018

Comentada:

el 2 de En. de 2019

Community Treasure Hunt

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

Start Hunting!

Translated by