Why did my single precision model generate double data type sine functions, using sin(real_T) instead of sinf(real32_T)?

5 views (last 30 days)
I am trying to generate code for TI target. My model has sine block for single data type signals. I found generated code have convert calculation to double data type. I expected it to use the single data type version of the sine function.
I guess the generated code would not be efficient. Is there any way to make the code to use a single version sin function?

Accepted Answer

MathWorks Fixed Point Team
One likely cause to trigger such "mis-match" is the C language standard: For C89/90, there was no single precision version of sin/cos. See this setting (screenshot attached) can be updated for your model. Single Precision Converter updates this setting in your model:
  • Check that the system uses a library standard that supports single-precision designs.To convert a system to single precision, the language standard must be set to C99 (ISO). If the specified language standard is not set to C99, the Single Precision Converter changes the math library.
You would see the desirable match.
Thanks!

More Answers (0)

Products


Release

R2025a

Community Treasure Hunt

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

Start Hunting!