Rocket Trajectorydsa

You might also like

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 5

Load Data - Define..............................................................................................

1
Velocity v Time................................................................................................... 1
Acceleration v Time............................................................................................ 2
Mach Numbers.................................................................................................... 2
G-Force............................................................................................................... 3
Plotting Graphs................................................................................................... 3

clear all;
close all;
clc;

Load Data - Define


load 'data.dat';
time = data(:,1);
alt = data(:,2);
step = time(2)-time(1);

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);

%Determine Max Value


maxvel = max(vel2);
[i,j] = find(vel2 == maxvel);
maxveltime = (max(time)/(length(vel2))*j);

maxveltimedisplay = ['The maxiumum speed is ', num2str(maxvel), ' m/s, which is reached at
', num2str(maxveltime), ' seconds.'];
disp(maxveltimedisplay);

The maxiumum speed is 3926.9 m/s, which is reached at 218.7513 seconds.

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);

%Determine max value


maxacc = max(acc);
[a,b] = find(acc2 == maxacc(1,1));
maxacctime = ((max(time)/length(acc2))*b);
maxacctimedisplay = ['The maxiumum acceleration is ', num2str(maxacc(1,1)), ' m/s^2,
which is reached at ', num2str(maxacctime), ' seconds.'];
disp(maxacctimedisplay);

The maxiumum acceleration is 114.22 m/s^2, which is reached at 206.5406 seconds.

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

Mach 1 is first reached at 1.2708 seconds.


Mach 2 is first reached at 9.3642 seconds.
Mach 3 is first reached at 17.9784 seconds.
Mach 4 is first reached at 183.2736 seconds.
Mach 5 is first reached at 188.0755 seconds.
Mach 6 is first reached at 191.7941 seconds.
Mach 7 is first reached at 195.5231 seconds.
Mach 8 is first reached at 199.023 seconds.
Mach 9 is first reached at 202.127 seconds.
Mach 10 is first reached at 205.2206 seconds.
Mach 11 is first reached at 208.3247 seconds.

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);

The Time above 9 gs is 16.1669 seconds

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)');

You might also like