MATLAB: How to convert the output of a Serial Receive block to char data type, and find the double equivalent of this on the Arduino

charcodegenerationsimulink coderstr2doublestr2num

How can I convert the output of a Serial Receive block to char data type, and find the double equivalent of this on my Arduino?

Best Answer

The Serial Receive block outputs uint8 data type. One approach is to feed the output of the Serial Receive block into a MATLAB Function block to do this conversion using the 'char' and 'str2double' functions since they are both supported for Code Generation.
For example, get u = 52 as uint 8, char(u) = 4, str2double(char(u)) = 4.
Note that the similar function 'str2num' is not supported for Code Generation.