필터 지우기
필터 지우기

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

조회 수: 4 (최근 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.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by