Filter löschen
Filter löschen

Help creating a graph

1 Ansicht (letzte 30 Tage)
Sam Griffiths
Sam Griffiths am 16 Mär. 2023
Bearbeitet: Sam Griffiths am 16 Mär. 2023
%% 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)
During first stage, the velocity reached was 459.988491 m/s,
fprintf('and the Height achived was %f meters. \n',HB1)
and the Height achived was 17665.851905 meters.
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
After the 10 second wait inbetween 1st Stage ECO, and Stage 2 ignition,
fprintf('the Velocity was %f m/s,\n',V_S)
the Velocity was 361.888491 m/s,
fprintf('and the Height achived was %f meters\n',Height)
and the Height achived was 18616.340396 meters
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)
At Stage 2 ECO, the Velocity was 963.251816 m/s
fprintf('and the Height achived was %f meters.\n',HB2)
and the Height achived was 37254.049791 meters.
fprintf('\n')
fprintf('At the end of the Coast Phase Velocity = 0,\n')
At the end of the Coast Phase Velocity = 0,
fprintf('as this is where the Maximum Height of %f meters is reached\n',Hmax)
as this is where the Maximum Height of 84545.286329 meters is reached
fprintf('To reach maximum Height it took %f seconds\n',Tmax)
To reach maximum Height it took 292.610038 seconds
% 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 Kommentare
Rik
Rik am 16 Mär. 2023
Have a read here and here. It will greatly improve your chances of getting an answer. What specifically is your question?
Sam Griffiths
Sam Griffiths am 16 Mär. 2023
Bearbeitet: Sam Griffiths am 16 Mär. 2023
Sorry for not making it clear, i have to create a graph using these equations that are commented out, and am struggiling on how to achive that, as t changes, as in the first eq t is 0-109, at stage sep it is 0-10, stage 2 it is 0-75, and finally us 0-96, meaning i cannot use a simple array for t. but has to be ploted against time going from 0-293. I could very easily be stupid and cannot see the simple solution.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Cameron
Cameron am 16 Mär. 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)

Kategorien

Mehr zu Mathematics finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by