title: Is there a C union functionality in MATLAB?
body: <p>I have some data that is being stored as an <code>Nx32</code> logical array. Each row represents one word of UDP data that I'm sending. I'm storing it as a logical array because I could access any word, part of a word, or even across word boundaries. (I.e., I might store a <code>uint32</code> as <code>[array(1, 17:32) array(2, 1:16)]</code>. Currently I find the data the user wants based on input word position, LSB, and MSB. </p>
  
  <p>The functionality I'm writing into the classes to read to/write from places in the data essentially require that I convert any given MATLAB numeric type or char into its binary form, then store the binary form into the logical array, or vice versa. Basically there's a lot of <code>num2hex</code> and other conversions. (Actually, I tried to convert a float to binary using, say,  <code>dec2bin(hex2dec(num2hex(pi)))</code> but the output is incorrect!).</p>
  
  <p>In C, a <code>union</code> could easily cast between data types. I could write an <code>int</code> and read it out as a <code>float</code> directly. Is this functionality possible in MATLAB? I do have access to all the toolboxes if that helps.</p>