Your if statement can be made to work, but I think a switch statement is a little cleaner.
There are lots of ways of handling the exiting from the loop. You might want to use
I went with a TF flag that is either true or false.
TF = true;
while TF
TF = false;
disp('Please Enter the Method:')
disp('1 – Aligrot Method')
disp('2 – Pishinger Method')
disp('3 – Watson Method')
UserInput = input('Enter the Number corresponding to the selective Method and Press ENTER: ');
switch UserInput
case 1
case 2
case 3
otherwise
warning('PLEASE READ CAREFULLY!!');
TF = true;
end
Best Answer