my while loop is only running two times then it stops

E=input('Please enter pipe roughness (1.5e-6 and 5.0e-4):'); %check to see if within range while E<1.5e-6 E>5.0e-4 %if not within range display: disp('The number has to be between 1.5e-6 and 5.0e-4') %try again E=input('Please enter a pipe roughness between 1.5e-6 and 5.0e-4:') end

 Accepted Answer

For me it looped and asked everytime I entered a number outside the requested range. Like I entered 1, 3, 9, etc. and it always came back and asked until I entered something like 5e-5. So I can't reproduce your problem.

More Answers (1)

ok, thanks for checking, on my second incorrect input it outputs E=*whatever the input was*, maybe its just my copy of matlab.

1 Comment

It works fine. I just copied and pasted. It's not your copy of MATLAB. Tell me exactly what you typed in.

Sign in to comment.

Tags

Community Treasure Hunt

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

Start Hunting!