 <p>The symbol <code>&amp;</code> is the <code>and</code> logical operator. You can use it for multiple conditions in your <code>while</code> loop.</p> <pre><code>while (user_input ~= 256 &amp; user_input ~= 128 &amp; user_input ~= 64) prompt = 'Please enter one of the listed gray levels (256, 128, 64, 32, 16, 8, 4, 2). '; user_input = input(prompt); end </code></pre> <p>As beaker pointed out, what you ask is to ask for input as long as it is not one of the following values : 256, 128 or 64. Using the <code>or</code> logical operator would mean that <code>user_input</code> should be 256, 128 and 64 at the same time to break the loop.</p> <hr> <p>You can also use <a href="http://fr.mathworks.com/help/matlab/ref/ismember.html" rel="nofollow"><code>ismember</code></a>.</p> <pre><code>conditionnal_values = [256, 128 , 64] while ~ismember(user_input, conditionnal_values) prompt = 'Please enter one of the listed gray levels (256, 128, 64, 32, 16, 8, 4, 2). '; user_input = input(prompt); end </code></pre> <hr> <p>An other way to go, proposed by Luis Mendo, is to use <a href="http://fr.mathworks.com/help/matlab/ref/any.html" rel="nofollow"><code>any</code></a></p> <pre><code>conditionnal_values = [256, 128 , 64] while ~any(user_input==conditionnal values) prompt = 'Please enter one of the listed gray levels (256, 128, 64, 32, 16, 8, 4, 2). '; user_input = input(prompt); end </code></pre> <p><code>user_input == conditionnal_value</code> returns an array composed of 1s and 0s depending on if values of <code>conditionnal_values</code> match with <code>user_input</code>. Then any finds if there is at least one <code>1</code> on this array. Then we apply <code>~</code> which is the <code>not</code> operator.</p>