h(1)=100000;
t(1)=0;
dt=0.005;
p(1)=(((h(1))/71)+1.4);
g(1)=(40*10^7)/(6371+h(1))^2;
A=5;
c=0.7;
m=850;
Fd(1)=0.5*c*(p(1))*a(1)*(v(1))^2;
v(1)=59.29;
a(1)=0.03535;
i=1;
while h(end)>=0
t(i+1)=t(i)+dt;
h(i+1)=100000-((v(i+1)*t(i+1))+(0.5*(a(i))*(t(i+1))^2));
p(i+1)=(((h(i+1))/71)+1.4);
Fd(i+1)=0.5*c*(p(i+1))*A*(v(i+1))^2;
g(i+1)=(40*10^7)/(6371+h(i+1))^2;
a(i+1)=g(i+1)-(Fd(i+1)/850);
v(i+1)=v(1)+(a(i+1)*t(i+1));
end
With this code I want to be able to plot graphs and get values for a and v. When I run it an error comes up either saying 'undefined function or variable a'. or 'undefined function or variable v'. One time I managed to stop these errors but I still got an error saying 'Index exceed number of array elements'. Any help would be appreciated.