Professional Documents
Culture Documents
Rocket Trajectorydsa
Rocket Trajectorydsa
Rocket Trajectorydsa
1
Velocity v Time................................................................................................... 1
Acceleration v Time............................................................................................ 2
Mach Numbers.................................................................................................... 2
G-Force............................................................................................................... 3
Plotting Graphs................................................................................................... 3
clear all;
close all;
clc;
Velocity v Time
timeVvel = time(2)*.5:step:time(end);
vel = diff(alt)./diff(time);
%Interpolate Velocity
tsrt = 1;
tend = 25;
tstp = 0.001;
x = tsrt:tend;
y = tsrt:tstp:tend;
vel2 = interp1(x,vel,y);
maxveltimedisplay = ['The maxiumum speed is ', num2str(maxvel), ' m/s, which is reached at
', num2str(maxveltime), ' seconds.'];
disp(maxveltimedisplay);
Acceleration v Time
timeVacc = time(2):step:time(end-1);
acc = diff(vel)/diff(time);
% Interpolate acceleration
tstp2 = 0.01;
w = tsrt:tend - 1;
z = tsrt:tstp2:tend - 1;
acc2 = interp1(w,acc(:,1),z);
Mach Numbers
mach1 = 340;
machmax = floor(max(vel2)/mach1);
machtime = zeros(1,machmax);
for i = 1:machmax
vel3 = round(vel2);
[c,d] = find(vel3 == i*mach1,1);
machtime(1,i) = ((max(time)/length(vel3))*d);
machtimedisplay = ['Mach ', num2str(i), ' is first reached at ', num2str(machtime(1,i)), '
seconds.'];
disp(machtimedisplay);
end
G-Force
nineGs = 9 * 9.81;
acc3 = round(acc2*100)/100;
gForceTime = find(acc3 >= nineGs);
MaxGtime = ((max(timeVacc)/length(acc2))*(max(gForceTime) - min(gForceTime)));
MaxGtime2 = ((max(timeVacc)/length(acc2))*(min(gForceTime)));
MaxGtime3 = ((max(timeVacc)/length(acc2))*(max(gForceTime)));
MaxGtimeD = ['The Time above 9 gs is ', num2str(MaxGtime), ' seconds'];
disp(MaxGtimeD);
Plotting Graphs
L = figure;
set(L,'name','Rocket Trajectory','numbertitle','off') %Set title name for fig 1
figure(1);
subplot(3,1,1); %Put all graphs in one figure
plot(time, alt);
title('Time vs Altitude'); %Label title
xlabel('Time (s)'); %Label axis
ylabel('Altitude (m)');
subplot(3,1,2);
plot(timeVvel, vel);
title('Time vs Velocity');
xlabel('Time (s)');
ylabel('Velocity (m/s)');
subplot(3,1,3);
plot(timeVacc, acc, MaxGtime2, nineGs, '.', MaxGtime3, nineGs, '.');
title('Time vs Acceleration');
xlabel('Time (s)');
ylabel('Acceleration (m/s^2)');