Hi! I can get a piece of code to run in my Matlab script, but not when I use the corresponding Simulink block.
I am using UDP as a way of piping live streams from Simulink to python (Blender, 3D software) In matlab I am simply using
u = udp(host,port);
fwrite(u, data, 'double');
and I am sending a simple array of numbers. This comes through nicely. However, using Simulink 'UDP Send', I get the wrong numbers (instead of 3.14 i get something to the power of negative 300, etc.). My first thought is that this is owing to a different data type being used, but there is no way to set 'double' in the Simulink block, and it is my understanding that Simulink uses 'double' as its standard data type anyway.
Is there a way to change the data type, or could my problem lie somewhere else?
The Python end of the solution looks like
data = self.request
socket = self.request
numOfValues = int(len(data) / 8)
info=struct.unpack('>' + 'd' * numOfValues, data)