title: Remove any column with same values in MATLAB
body: <p>I need to remove any column in a matrix which has same values in it.  I designed it using a for-loop in MATLAB.  I wanted to know if a better/faster way exists using vectorization.</p>
  
  <pre><code>mat = [ 0.56  0.2 1 0 45; 0.566 0.2 4 0 45; 0.52  0.2 6 0 45; 0.56  0.2 6 0 41 ];  
  [row col] = size(mat) ;
  
  bitmat = true(1,col) ;
  for i = 2:row, tf = (mat(i-1,:) == mat(i,:)) ; bitmat = bitmat &amp; tf ; end
  mat(:,bitmat) = [] ;
  </code></pre>
  
  <p>Thanks!</p>