How do i resolve this error message?

I keep getting this error can anyone help?
Array indices must be positive integers or logical values.
Error in Assignment_3_Question_2 (line 24)
m(i)=5000*dt - m(t-dt);
Here is the code:
clear
dm=5000;
dt=1;
t=0:dt:1000;
Ve=4500;
G=6.67408e-11;
M=5.9722e24;
R=6371;
A=75;
Cd=0.4;
p=zeros(1,length(t));
m=zeros(1,length(t));
V=zeros(1,length(t));
h=zeros(1,length(t));
p(1)=1.225;
m(1)=894000;
m_final=54000;
V(1)=0;
h(1)=0;
for i=1:length(t)
if m(i)~=m_final
m(i)=5000*dt - m(t-dt);
else
m(i)=-m(t-dt);
end
p(i)=1.225*e(-3*h(i)/50000);
h(i)=h(t-dt)+((dt(V(t)+V(t-dt))))/2;
V(i)=Ve-((Ve*m(t))/m(t-dt))-((dt*G*M)/(R+h(t-dt)).^2)-((dt*p(h(t-dt)))*A*Cd*(V(t-dt)).^2)/2*(m(t-dt))+V(t-dt);
end
plot(t,V,'or')
xlabel('Time(s)')
ylabel('Velocity(m/s)')

Réponses (1)

Star Strider
Star Strider le 21 Avr 2020
I cannot determine what you want to do in this assignment:
m(i)=5000*dt - m(t-dt);
or this one:
m(i)=-m(t-dt);
since those appears to be throwing the error.
Perhaps:
m(i)=5000*dt - m(i)*(t(i)-dt);
or something similar in the other one as well will do what you want.
.

Catégories

En savoir plus sur Data Type Identification dans Centre d'aide et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by