MATLAB: Changing switch statement to while loop

while loop

I'll paste my script, but I was wondering how to change my switch statement to a while loop. With the switch if the user enters incorrect info, they can only correct one piece of it. If i make a while loop then I want the user to be able to correct as much as they want. Do i need a while loop for each piece of info?

Best Answer

You can use the menu in the while loop as follows:
while menu('Information Correct?','Yes','No') == 2
wrong = menu('What is Wrong?','Name','Age','City','State','Zip');
switch wrong
case 1 % Name is Wrong
Name = input('Enter your name: ','s');
case 2 % Age is Wrong
Age = input('Enter your age: ');
case 3 % City is Wrong
City = input('Enter your City: ','s');
case 4 % State is Wrong
State = input('Enter your State: ','s');
case 5 % Zip Wrong
Zip = input('Enter you Zip code: ');
end
end
% while loop left, everything is correct
fprintf('Nice Work! \n')