title: Storing matlab array in MySQL. Again
body: <p>I have a 3D array in Matlab of uint16(basically it is just an image 1080x1920x3). I want to store it in mysql. Here is what I'm doing:</p>
  
  <p>MySQL:</p>
  
  <pre><code>create table imgtest(img longblob);
  </code></pre>
  
  <p>Matlab:</p>
  
  <pre><code>% image_data - is my image as described before
  raw_im = reshape(image_data,1,[]);
  conn = database('test','root','root','Vendor','MySQL','Server','localhost')
  x = conn.Handle;
  insertcommand = ['INSERT INTO imtest (img) values (?)'];
  StatementObject = x.prepareStatement(insertcommand);
  StatementObject.setObject(1,raw_im)
  StatementObject.execute
  </code></pre>
  
  <p>The problem is that I'm writing about 600k uint16 values into this blob field. But when I take this field from the DB, I always getting about 1.2 million of uint8 elements(exactly two times more).</p>
  
  <p>So, is there a way to read this byte field as a set of uint16, but not uint8?</p>
  
  <p>Thank you.</p>