Simulating Rocket trajectory in three dimensions

28 views (last 30 days)
I'm working on an Aero project where we need to produce tabular outputs and plots of a rocket after it is fired from an aircraft. I'm having trouble figuring out how to code this up. I have an input vector of initial position and velocity and also a vector of time, thrust and mass of which I can use interp1 to get values for. Heres a sample of where I am trying to go. Basically how do I use these interpolations to model the flight?
timeCurve = [0 .078 .1793 .2793 .3793 .4821 .5821 .6821 .7821 .8821 .9821 1.0821 1.112 1.113 100]'; %Time after launch in seconds for thrust and mass
thrustCurve = [6291.32 6291.32 5593.8 5437.6304 5325.5352 5304.5963 5574.8825 6002.2084 6429.5343 6638.2227 7963.6388 2693.809 740.8514 0 0]'; % Thrust in Newtons
massCurve = [10.4319 10.1886 9.8901 9.6176 9.3507 9.0666 8.7719 8.4845 8.1759 7.8474 7.4813 7.1776 7.1545 7.1368 7.1368]'; % Rocket mass in kg
machCurveB = [.1 .3019 .4655 .6295 .8082 .9984 1.1866 1.3931 1.6186 1.8782 2.0964 2.1066 2.25]; % Mach numbers for drag coefficient in boost phase
dragCurveB = [.55 .5502 .5509 .5505 .5684 .6841 .7479 .7555 .7367 .6925 .6624 .6611 .64]; % Drag coefficients in boost phase
machCurve = [.1 .7841 .8258 .8616 .9024 .95 1.0027 1.0956 1.21 1.3371 1.4028 1.6031 1.8107 2.024 2.1066 2.25]; % Mach numbers for drag coefficient in coast phase
dragCurve = [.7 .7031 .7357 .7711 .8122 .8791 .9615 .9988 1.0106 1.0053 .9983 .9647 .9115 .8543 .834 .8]; % Drag coefficients in coast phase
if true
% % Rocket 3DOF
%%Define simulation control parameters
%%Initial Conditions
% Initial position, velocity, attitude, etc.
xDot = dxdt(t0,xVector);% xDot = [velocity and acceleration]. dxdt is a function.
t0 = 0; %start time
% Start recording data for output & plots
output_vector(1, :)= [t0,xVector',xDot(4:6)',el]; % xVector = [position velocity]'
%%Trajectory Computation Loop
t = t0;
for ind = 2:maxNum;
[time,x]=ode45(@dxdt,[t t+dt],xVector);% x and time are values of xVector at t+dt
% Calculate trajectory parameters based on states
if xVector(3) < zImpact && xVector(6) < 0 ; % termination condition
%compute impact conditions
output_vector(ind,1:4) = [t_impact, IP_x, IP_y, IP_z];
break;
end
end
csvwrite('trajectory.csv',output_vector); % write .csv file
%%Plot results
figure(1)
clf
grid on;
plot(output_vector(:,1),output_vector(:,10),'linewidth',2)
grid on;
figure(2)
clf
grid on;
plot(output_vector(:,3),output_vector(:,4),'linewidth',2)
grid on;
end
  2 Comments
Jim Riggs
Jim Riggs on 1 Oct 2019
Edited: Jim Riggs on 1 Oct 2019
This question seems to be "How do I make a pointmass simulation?"
The answer is a bit involved. If you are still looking for an answer, post a comment here and I will talk you through it. I'm sure that many other people would benefit from such a discussion, so I don't mind putting in the time if there is interest.
(To the editors: I wish that you would remove the answer that simply asks a question)
John D'Errico
John D'Errico on 1 Oct 2019
Edited: John D'Errico on 1 Oct 2019
Done. Moved an answer from Raviraj SR into a comment:
Did you get the answer for the above problem?"
@Raviraj SR - Please don't add answers just to ask a question. Use comments.
Jim - my own take is, that as an untouched 3 year old question, it drew no interest at the time, and Logan has certainly moved on since. Note that Logan has made no other posts on Answers before or after this question. But if you want to put in the time, go for it, since there is now some interest from Raviraj.

Sign in to comment.

Answers (0)

Categories

Find more on Aerospace Applications in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!