i can't get my while loop to work

i need this while loop to work but it just keep auto repeating isntead of asking the question to the user
RunAgain == 1
while RunAgain == 1
%my code
RunAgain = input ('\nWould you like to run this again?(1 for yes 0 for no)? ');
while isempty (RunAgain) == 1 || RunAgain ~= 1 && RunAgain ~= 0
RunAgain = input ('\nERROR, Would you like to run this again?(1 for yes 0 for no)? \n ');
end
if you could keep it in this format that would be great! i think the problem in where the double && sign is but im not sure what or how to change it

2 Comments

What exactly uou want to do? isempty (RunAgain) == 1, this could be simply isempty(RunAgain).
I need it to ask the user if they would like to run the code again but it doesn’t want to out put the question instead it just repeats the code

Sign in to comment.

Answers (1)

while ~(isequal(RunAgain, 0) || isequal(RunAgain, 1))

Categories

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

Products

Release

R2021b

Asked:

on 3 May 2022

Answered:

on 3 May 2022

Community Treasure Hunt

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

Start Hunting!