Help creating a graph
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
%% Question 1 %%
% A two stage, solid-propellant sounding rocket %
clc
clear
format ShortG
% Cosntants %
g = 9.81; % Gravity (m/s^2)
Dp = 2.2; % Parachute Diamter (m)
Cdp = 0.8; % Parachute Drag Coefficent
rho0 = 1.225; % Density (Kg/m^3)
% Stage 1 Properties %
m0_1 = 600; % Inital Mass (Kg)
mf1 = 350; % Final Mass (Kg)
T = 6500; % Thrust (N)
Isp1 = 270; % Specific Impulse (s)
% Stage 2 Properties %
m0_2 = 100; % Initial Mass (Kg)
n2 = 1.6; % Mass Ratio
me2 = 0.5; % Mass Flow Rate (Kg/s)
Isp2 = 290; % Specific Impulse (s)
% Stage 1 Calculations
C1 = Isp2*g; % 1st Stage Effective Exaust Velocity (m/s)
me1 = T/C1; % 1st Stage Mass Flow rate
TB1 = (m0_1-mf1)/me1; % Time Since T+0 at Burnout
VB1 = C1*log(m0_1/mf1)-(g*TB1); % Velocity at Burnout
HB1 = C1*((-(mf1/me1))*log(m0_1/mf1)+TB1)-((g*TB1^2)/2); % Height at Burnout
% Stage Separation
Time = 10; % Time Delay
V_S = VB1-(g*Time); % Velocity at End of Stage Sep
ChangeH = VB1+0.5*g*Time^2; % Change in height during Stage Sep
Height = HB1+ChangeH; % Height of Rocket At End of Stage Sep
% Stage 2 Calculations
mf2 = m0_2/n2; % Final Mass
C2 = Isp2*g; % Effective Exaust Velocity (m/s)
TB2 = (m0_2-mf2)/me2; % Time Taken During Burn
VB2 = V_S+(C2*log(m0_2/mf2)-(g*TB2)); % Velocity Increase During Burn
HB2 = Height+(C2*((-(mf2/me2))*log(m0_2/mf2)+TB2)-((g*TB2^2)/2)); % Height Increase During Burn
% Total Time After Final Stage
TotalT = TB1+Time+TB2;
% Coast Phase
Tmax = TotalT+(VB2/g); % Time Since T+0
Hmax = HB2+((VB2^2)/(2*g)); % Max altitude Reached at end of flight
% V ends up being 0 in the upward direction as that is when H is Maximum
fprintf('During first stage, the velocity reached was %f m/s, \n', VB1) % Printing Velocity and Height at Stage 1 ECO (Engine Cut Off)
fprintf('and the Height achived was %f meters. \n',HB1)
fprintf('\n')
fprintf('After the 10 second wait inbetween 1st Stage ECO, and Stage 2 ignition,\n') % Printing to console the Velocity and Height at the end of the 10 Coast Phase inbetween stages
fprintf('the Velocity was %f m/s,\n',V_S)
fprintf('and the Height achived was %f meters\n',Height)
fprintf('\n')
fprintf('At Stage 2 ECO, the Velocity was %f m/s \n',VB2) % Printing to console the Velocity and Height at Stage 2 ECO (Engine Cut Off)
fprintf('and the Height achived was %f meters.\n',HB2)
fprintf('\n')
fprintf('At the end of the Coast Phase Velocity = 0,\n')
fprintf('as this is where the Maximum Height of %f meters is reached\n',Hmax)
fprintf('To reach maximum Height it took %f seconds\n',Tmax)
% Creating the graphs
% Stage 1 Velocity
% m = m0_1-me1*t;
% V = C1*log(m0_1/m)-(g*t);
% Use above equations when time is between 0 and 109
% Stage Separation, lasts for 10 seconds so from 110-120
% V = VB1-(g*t); % time needs to go from 1-10 here
% Stage 2 velocity, From 121-195
% m2 = m0_2-me2*t;
% V = C2*log(m0_2/m2)-(g*t);
% Coasting Phase, from 196 to 293
% V = VB1-(g*t);
% These need to be plotted agagint time ranging from 0-Tmax (292.61)
% Also each phase needs a different line colour, and a marker at the start and end of each [hase
2 comentarios
Respuestas (1)
Cameron
el 16 de Mzo. de 2023
m0_1 = 600;
g = 9.81;
T = 6500;
Isp2 = 290;
C1 = Isp2*g;
me1 = T/C1;
mf1 = 350;
TB1 = (m0_1-mf1)/me1;
VB1 = C1*log(m0_1/mf1)-(g*TB1);
me2 = 0.5;
m0_2 = 100;
C2 = Isp2*g;
t1 = 0:109;
m1 = m0_1-me1*t1;
V1 = C1*log(m0_1./m1)-(g*t1);
t2 = 110:120;
V2 = VB1-(g*t2);
t3 = 121:195;
m3 = m0_2-me2*t3;
V3 = C2*log(m0_2./m3)-(g*t3);
t4 = 196:0.01:292.61;
V4 = VB1-(g*t4);
t = [t1,t2,t3,t4];
V = [V1,V2,V3,V4];
plot(t,V)
0 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!