Answer:
load('ROCKET_DATA.CSV')
m=ROCKET_DATA;
plot(m(:,1),m(:,2))
hold on
x=m(:,1);y=m(:,2);
b=length(m);
%% finding/plotting velocity
for i=2:b
if i==b
v(i)=NaN;
else
%v(i)=(y(i+1)-y(i-1))/(2*(x(i+1)-x(i-1))); centered difference
v(i)=(y(i+1)-y(i))/(x(i+1)-x(i)); %forward difference
end
end
plot(x,v);
%% finding acceleration
for i=3:b
if i==b
a(i)=NaN;
else
a(i)=(y(i+1)-2*y(i)+y(i-1))/(x(i+1)-x(i-1))^2; %cd of 2nd dy/dx
end
end
plot(x,a)
%% Max altitude
maxy=y(1);
for i=1:length(x)
if y(i)>maxy
maxy=y(i);
end
end
%% maximum velocity
maxa=v(1);
for i=1:length(v)
if v(i)>maxa
maxa=v(i);
end
end
%% maximum acceleration
maxa=a(1);
for i=1:length(a)
if a(i)>maxa
maxa=a(i);
end
end
%% Free body
mass=2.7;%gram
mass=.0027;%kilogram
N=mass*maxa; %(N); %N=the opposing force (minimum strength of the nose cone) at the maximum downward force
%% thruster time
t=0;
for i=1:length(a)
if a(i) < 0
t=i;
return
end
end