How to use double precision functions in a single precision code generated project?

1 次查看(过去 30 天)
Hey,
So if you create a code generation project and set 'Numberic Conversion:' to 'convert to single precision'.
Is there any way to call function that requires double inputs like bitshift in the project?
I get the error, "Function 'bitshift' is not defined for values of class 'single'." during the code generation process.
I tried casting my inputs as double() and using the cast() function but it seems that the conversion will not even let me change variables to double for function calls.
Is this expected?
Brian

回答(1 个)

Fangjun Jiang
Fangjun Jiang 2020-7-27
It is not a matter of double or single. The supported data types for this block is "Supported data types: Fixed-point, integer (signed or unsigned), Boolean". Specify the proper data type and then proceed.
  1 个评论
Scott McNeil
Scott McNeil 2023-3-7
Should I consider to rebuild the model from scratch, specifying desired data types from the beginning? We have not been able to retro-actively change the data types throughout the model without converters or Cast blocks. They create more overhead for the code. The model was first made without consideration to what type of data our controller will need.

请先登录,再进行评论。

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by