I have received the data from a socket. In Matlab, this data is converted into single precision by the following function
data_cal_rx = typecast(data_tcp2, "single");
Now I would like to have the same function in Python. Searching from google and Stack overflow, I saw that the single precision in Python is numpy.float32. So I replace by the following function:
import numpy as np
data_cal_rx = np.float32(data_tcp2)
data_tcp2 in Matlab is an array interger numbers with: class: uint8 dimension: 1x70848
however, when I received data_tcp2 by socket in Python, it is displayed as:
... \x00\x00C\x00 QE\x00 \x04E\x00 'E\x00BE\x00D\x00\x00LE\x00\x00\x10*E\x00`\x00@D\x00\x10+\x00\x00C\x000I\x00\x00A\x00\x16\x00\x13\x00 ...
And I got this error from the terminal in python:
ValueError: could not convert string to float:
It could be a problem with socket in python? Any help or idea would be greatly appreciated.
Thank you very much