1. Engineering
2. Mechanical Engineering
3. you plan to launch a rocket you are to write...

# Question: you plan to launch a rocket you are to write...

###### Question details

You plan to launch a rocket, you are to write a program that will calculate flight trajectory without wind resistance. Your program is to utilize the finite difference approach for calculating trajectory parameters every 0.01 seconds until it hits the ground.

Complete the matlab code with the while loop and indexing to create values for acceleration, velocity, height, mass, kinetic energy, potential energy, and total energy.

time(i)=0;
dt=0.01; % change in time
height(i)=1;% elevation
i=1;
BR=4.8; % burn rate
mfuel(i)=134; % mass fuel
mtot=150; % total mass
mcase=16; % mass of casing
fthrust(i)=1560; % force of thruse
athrust(i)=0; % thrust acceleration
ag=-9.81; % acceleration of gravity
atot(i)=athrust(i)-ag; % total acceleration
v(i)=0; % velocity
ke(i)=0; % kinetic energy
pe(i)=0; % potential energy
te(i)=0; % total energy
while height > 0
time(i+1)=time(i)+dt;
mfuel(i+1)=max((mfuel(i)-BR*dt),0); % add if statement to make sure mfuel isnt <0
mtot(i+1)=mfuel(i+1)+mcase;
fthrust(i+1)=1560*sign(mfuel(i+1)); % -1 if neg 0 if zero 1 is pos
athrust(i+1)=fthrust(i+1)/mtot(i+1);
v(i+1)=v(i)+((atot(i+1)+atot(i))/2)*dt;
height(i+1)=height(i)+((v(i+1)+v(i))/2)*dt;
ke(i+1)=1/2*mtot(i)*v(i)^2;
pe(i+1)=mtot(i)*(-g)*height(i);
te(i+1)=pe(i)+ke(i);
end