Please help, trying to run while loop but it says that "Index exceeds matrix dimension" in "while(H(i)>Ha)". Guess I have a problem with increment and the size of Hs. Thank you in advance.
% Input Data
As = 5; % cross-sectional area of the spacecraft (m^2)
Ap = 150; % parachute area (m^2)
Hs = 150; % initial height (km)
U = 0; % initial velocity (m/s)
Hp = 3; % parachute deployment height (km)
Ha = 100; % height of the atmosphere above the earth (km)
M = 850; % mass of the spacecraft (kg)
C = 0.7; % drag coefficient
Tstep = 0.1; % time step (s)
% Increment initialisation
i=1; H(i)=Hs; v(i)=0; s(i)=0; t(i)=0; %freefall without atmosphere
while(H(i)>Ha) FD=0; g(i) = (40*10^7)/(6371+H(i))^2; a(i) = g(i); % As FD = 0
s(i+1)= U*Tstep + 0.5*a(i)*(Tstep^(2)); v(i+1)= U + a(i)*Tstep; i=i+1; continue end
Best Answer