Rocket Engine Thrust, Code Running Infinitely [Homework]
14 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hi!
Background:

Code:
%% Problem 1. Rocket
clear all
clc
a=1;
g=9.81;
% a.)
t=0;
while(1)
v=3.5*(1/a*t*exp(a*t)-(1/a^2)*exp(a*t)+1/a^2)-g*t;
if v>300,break,end
t=t+0.0001;
end
t
h=3.5*(1/a^2*t*exp(a*t)-2/a^3*exp(a*t)+2/a^3+1/a^2*t)-g*t^2/2
% b.)
alf=1:0.1:5;
t=zeros(1,length(alf));
for i=1:length(alf)
while (1)
v=3.5*(1/alf(i)*t(i)*exp(alf(i)*t(i)))-(1/alf(i)^2)*exp(alf(i)*t(i))+1/alf(i)^2-g*t % first should equal 3.5973
if v>300,break,end
t(i)=t(i)+0.0001;
end
end
It seems to just run on and on, and I'm not seeing where I screwed up this code.
1 Commento
Walter Roberson
il 8 Mar 2021
%% Problem 1. Rocket
a=1;
g=9.81;
% a.)
t=0;
while(1)
v=3.5*(1/a*t*exp(a*t)-(1/a^2)*exp(a*t)+1/a^2)-g*t;
if v>300,break,end
t=t+0.0001;
end
t
h=3.5*(1/a^2*t*exp(a*t)-2/a^3*exp(a*t)+2/a^3+1/a^2*t)-g*t^2/2
% b.)
alf=1:0.1:5;
nalf = length(alf);
t=zeros(1,nalf);
vrecord = zeros(1,nalf);
for i=1:nalf
while (1)
v=3.5*(1/alf(i)*t(i)*exp(alf(i)*t(i)))-(1/alf(i)^2)*exp(alf(i)*t(i))+1/alf(i)^2-g*t(i); % first should equal 3.5973
if v>300,break,end
t(i)=t(i)+0.0001;
end
vrecord(i) = v;
end
plot(t, vrecord); drawnow
Risposte (0)
Vedere anche
Categorie
Scopri di più su Startup and Shutdown in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
