title: Reading data from Simulink into Python over UDP
body: <p>I want to send data from a Simulink model (running in real time) to a Python script (also running in real time.  I am using Simulink's built-in "UDP Send" block, which works, but I don't know how to decode the data I'm getting.  This is what my python script looks like:</p>
  
  <pre><code>import sys, struct
  from socket import *
  
  SIZE = 1024      # packet size
  
  hostName = gethostbyname('0.0.0.0')
  
  mySocket  = socket( AF_INET, SOCK_DGRAM )
  mySocket.bind((hostName,5002))
  
  repeat = True
  while repeat:
      (data,addr) = mySocket.recvfrom(SIZE)
      data = struct.unpack('d',data)
      print data
  </code></pre>
  
  <p>I've suspected that the data stream should be something like a double, but while it's giving me numbers they aren't meaningful:</p>
  
  <ul>
  <li><p>If simulink sends a constant "1", I get an output of "3.16e-322"</p></li>
  <li><p>If Simulink sends a constant "2", I get an output of "3.038e-319"</p></li>
  </ul>
  
  <p>Any ideas?</p>