Going from one while loop to another
Show older comments
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 Comment
Accepted Answer
More Answers (0)
Categories
Find more on Automotive in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!