Going from one while loop to another
Ältere Kommentare anzeigen
Is there a way to go to another while loop when the condition's of the first loop have been met? For example:
clear
t(1)=0;
h(1)=150*10^3;
v(1)=0;
a(1)=(40*10^7)/(6371+(150*10^3))^2;
dt=0.1;
i=1;
while h >= 100*10^3
t(i+1) = t(i)+dt;
a(i+1) = (40*10^7)/(6371+(h(i)))^2;
v(i+1) = (v(i)+(a(i)*t(i)));
h(i+1) = (h(i))-(v(i)*(t(i))+1/2*a(i)*(dt)^2);
i=i+1
end
while 0 > h >= 100*10^3
t(i+1) = t(i)+dt;
a(i+1) = (40*10^7)/(6371+(h(i)))^2;
v(i+1) = (v(i)+(a(i)*t(i)));
h(i+1) = (h(i))-(v(i)*(t(i))+1/2*a(i)*(dt)^2);
i=i+1
end
When loop 1 is finished is their a way for loop 2 to start with the values that loop 1 had at the end if it's loop?
1 Kommentar
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Automotive finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!