I am attempting to typecast some data from int32 to single. I first tried using the 'Data Type Conversion' block with single output data type and the Stored Integer option. However, I found that the datatype conversion block is not typecasting the data the way I expect it to. Am I using the block incorrectly, or is it failing to work as i开发者_如何学运维t should?
temp1 (pre conversion): uint32: 1405695244 single: 1728356810752.000000 binary: 01010011110010010011010100001100
temp2 (post conversion): uint32: 1319604842 single: 1405695232.000000 binary: 01001110101001111001001001101010
By the way, I have gotten around the issue by using an embedded Matlab block to perform the typecasting operation.
"Convert" block crop the number. I would suggest to use Matlab Embedded function with "typecast".
function out_single = typecasting(in_uint32)
out_single = typecast(in_uint32, 'single');
精彩评论