title: How can I hot one encode in Matlab?
body: <p>Often you are given a vector of integer values representing your labels (aka classes), for example</p>
  
  <pre><code>[2; 1; 3; 3; 2]
  </code></pre>
  
  <p>and you would like to hot one encode this vector, such that each value is represented by a 1 in the column indicated by the value in each row of the labels vector, for example</p>
  
  <pre><code>[0 1 0;
   1 0 0;
   0 0 1;
   0 0 1;
   0 1 0]
  </code></pre>