- Ask a question;
- Copy all the red text from any error messages your code throws from your Command Window and paste it to a Comment here.
Two Stage Rocket zeroing a value and indices must be a positive real interger?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
if true
function TWOSTGSPR
clc
clear all
%%Part A
%%Variables
g0 = 9.81; % gravity
m01 = 249.5; m02 = 113.4; % Intial mass of rocket
mf1 = 170.1; mf2 = 58.97; % Mass of rocket after an engine burn over a period of delta T
rme1 = 11.1; rme2 = 4.05; % Rate at which exhaust mass flows accross the nozzle exit plane
Isp1 = 235; Isp2 = 310; % Impulse
c1 = Isp1*g0; c2 = Isp2*g0; %
%%Stage 1
ts1bo = (m01-mf1)/rme1; % Time till burnout stage 1
ts1 = ts1bo+3; % Time after delay
hs1bo = (c1/rme1)*(mf1*log(mf1/m01)+m01-mf1)-0.5*(((m01-mf1)/rme1)^2*g0); % Stage 1 Burnout Height
vs1bo = c1*log(m01/mf1)-g0*((m01-mf1)/rme1);
vs1bo3 = vs1bo-g0*(ts1-ts1bo);
hs1bo3 = hs1bo + vs1bo3*(ts1-ts1bo)-0.5*g0*(ts1-ts1bo)^2;
%%Stage 2
ts2max = (m02-mf2)/rme2;
ts2bo = (m02-mf2)/rme2; % Time till burnout stage 2
vs2bo = c2*log(m02/mf2)-g0*((m02-mf2)/rme2);
hs2bo = hs1bo3+(c2/rme2)*(mf2*log(mf2/m02)+m02-mf2)-0.5*(((m02-mf2)/rme2)^2*g0); % Stage 2 Burnout Height
%%Max Height
n = m02/mf2; % A constant with a variable of n
hmax = hs1bo3+0.5*((c2^2)/g0)*(log(n)^2)-(c2/rme2)*m02*((n*log(n)-(n-1))/n); % Max Height
%%Display
fprintf("Height at Burnout in First Stage: %gm \nHeight at Burnout in Second Stage: %gm \nMax Height: %gm ",hs1bo, hs2bo, hmax);
%%Part B
t1 = 0:0.001:ts1;
t1a = ts1bo:0.001:ts1;
hs1 = (c1/rme1)*((m01-rme1*t1).*log((m01-rme1*t1)/m01)+rme1*t1)-(0.5.*(t1.^2)*g0);
vs13 = vs1bo - g0*(t1-ts1bo);
hs13 = hs1bo+vs1bo.*(t1-ts1bo)-0.5*g0*((t1-ts1bo).^2);
if t1<=ts1bo
h1 = hs1;
elseif t1>ts1bo
h1 = hs13;
end
plot(t1,h1,'b')
hold on
%
t1 = 0:0.001:ts1;
hs1 = (c1/rme1)*((m01-rme1*t1).*log((m01-rme1*t1)/m01)+rme1*t1)-(0.5.*(t1.^2)*g0);
end
3 comentarios
Stephen23
el 22 de Mzo. de 2018
@David Oshidero: we cannot guess where the error occurs or what it says exactly. Please show us the complete error message. This means all of the red text.
David Oshidero
el 22 de Mzo. de 2018
Editada: Image Analyst
el 22 de Mzo. de 2018
Respuestas (2)
James Tursa
el 22 de Mzo. de 2018
Editada: James Tursa
el 22 de Mzo. de 2018
In this line:
hs13 = hs1bo+vs1bo(t1-ts1bo)-0.5*g0*((t1a-ts1bo).^2);
This
vs1bo(t1-ts1bo)
was probably meant to be this:
vs1bo*(t1-ts1bo)
But then you will have a dimension mismatch error to fix. So maybe you also need to change the t1 to t1a or vice-versa?
Also, I doubt that the if-test here is doing what you think it is doing since t1 is a vector and not a scalar:
if t1<=ts1bo
h1 = hs1;
elseif t1>ts1bo
vs13 = vs1bo - g0*(t1-ts1bo);
h1 = hs13;
end
You should re-examine this if-test to see what it should really be.
2 comentarios
David Oshidero
el 22 de Mzo. de 2018
I will recheck my code once i am home. there was a few things I didn't understand whilst doing it but I thought it would work. thanks for the help ill give a proper reply after trying again
Ver también
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!