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

2 visualizaciones (últimos 30 días)
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

Respuestas (1)

Fangjun Jiang
Fangjun Jiang el 27 de Jul. de 2020
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 comentario
Scott McNeil
Scott McNeil el 7 de Mzo. de 2023
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.

Iniciar sesión para comentar.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by