While Loops- Flaps Problem, need advice

1 回表示 (過去 30 日間)
Kyle
Kyle 2011 年 3 月 10 日
I have a program that sets the flaps on an airplane(Theoretically) up and down 5 degrees each time, but when i get to 30 is should only display Flaps Full DOWN, and when it gets to 0 is should be Flaps Full UP and shouldnt display the degrees. Is there a function that will get me out of the elseif statemnt? because break; gets me out of the whole program. Heres my program:
%Glass cockpit flap simulator:
total=0;
cnt=0;
again = true;
while again==true
let=lower(input('U for up, D for down, Q for quit:','s'));
cnt=cnt+1;
if let~='u' && let~='d' && let~= 'q'
fprintf('Please enter a valid response!\n')
elseif let=='u' && total>0
total=total-5;
if total==0
fprintf('Flaps Full UP')
end
fprintf('Flaps at %g degrees\n',total)
elseif let=='d' && total<30
total=total+5;
if total==30
fprintf('Flaps Full DOWN')
end
fprintf('Flaps at %g degrees\n',total)
elseif let=='q'
fprintf('Thanks for testing your flaps design!\n')
again=false;
elseif total== 30
fprintf('Flaps Full DOWN\n')
elseif total==0
fprintf('Flaps Full UP\n')
end
end

採用された回答

Sean de Wolski
Sean de Wolski 2011 年 3 月 10 日
If total >= 30
%flaps full down
end
Also read:
doc le
doc ge
doc lt
doc gt

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by