How to insert a loop into a program?

My engineering class is learning how to write programs in matlab, and so I got bored during one of my classes and started reading ahead and begin writing a program to determine someone's age and how many days until their next birthday. Given my inexperience with writing code, the program is super long, but it works flawlessly. I'm only having one problem...
After the user inputs their year, day, and month of birth, and also the current year, day, and month, the program asks if the information they have put in is correct in a menu and their options are "yes" or "no". Write now no matter what they select nothing happens because I don't know how to set up the loop. If they answer yes i want the program to just keep going, and if they answer know, i want the program to loop back to that set of questions again until they answer yes. How do I do this?

Answers (1)

need_the_info = true;
while need_the_info
....
if strcmpi(user_reply,'Yes')
need_the_info = false;
break;
end
end

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Products

Tags

Asked:

on 9 Feb 2011

Community Treasure Hunt

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

Start Hunting!