title: How to generate a random integer that is either 0 or 1 in MATLAB
body: <p>I searched the MATLAB documentation for how to generate a random integer that is either a 0 or a 1.</p>
  
  <p>I stumbled upon the two functions randint and randi.
  randint appears to be deprecated in my version of MATLAB although it is in the documentation online and randi appears to only create randoms numbers between 1 and a specified imax value.</p>
  
  <p>I even created my own randint function to solve the problem although it doesn't run very efficiently in my program since it is used for large data sets:</p>
  
  <pre><code>function [ints] = randint(m,n)
  ints = round(rand(m,n));
  end
  </code></pre>
  
  <p>Is there a built-in function to create a random integer that is either a 0 or 1 or is there a more efficient way to create such a function in MATLAB?</p>