How to create structure with while loop?

1 Ansicht (letzte 30 Tage)
Vy Nguyen
Vy Nguyen am 14 Okt. 2015
Beantwortet: Muthu Annamalai am 29 Okt. 2015
Hello,
I don't understand what my instructor means by this, can someone explain for me? Thanks!
Create a script containing a while loop that checks for a yes response to continue (we did this in class – you must set an initial “answer” to ‘y’ at the beginning of the loop, then take a character input at the end of everything to check for exiting. Use strcmpi to compare the “answer” to ‘y’).
  1 Kommentar
James Tursa
James Tursa am 14 Okt. 2015
Please post what you have done so far and then ask specific questions about where you are having trouble. What does a structure have to do with the 'y' while loop?

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Muthu Annamalai
Muthu Annamalai am 29 Okt. 2015
Hello Vy, You are looking for a event loop like this,
answer = 'y'
while strcmpi(answer,'y')
%do something
answer = input('Do you want to continue (y/n) ? ','s')
end
I also recommend you look at the
help input

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by