title: Type casting a vector in Matlab
body: <p><strong>version: Matlab 2009a</strong></p>
  
  <p>I am generating a vector of size &lt;1x116286> using randsrc() function. Since I am again adding it to the matrix of same size but of uint8 type, I am doing as follows -</p>
  
  <pre><code>l=typecast(randsrc(1,v(2)),'uint8');
  </code></pre>
  
  <p>Now, Matlab has changed the returned a vector of elements - [240,63,0] instead of [-1,1], with the size of &lt;1x930288 uint8>. This is expected as double and uint8 has different size, but I want a vector of same size and values after type casting.</p>
  
  <p>PS: I want to subtract or add '1' from all trhe values on a matrix of size &lt;1x116286>. Is there any other neat way to do this?</p>