If your goal is to generate efficient, inlined code for mod by a known constant, use the Modulo by Constant block rather than the two-input Mod block.
Why:
- Two-input Mod block: The second input is treated as a signal, not as a literal constant during code generation. For floating-point, this commonly results in a call to a runtime helper (e.g., rt_modf_snf(u, 360.0F)) to preserve numerical behavior across edge cases.
- Modulo by Constant block: The modulus is a parameter (compile-time constant). Embedded Coder can inline the operation and select specialized implementations. Docs links: https://www.mathworks.com/help/fixedpoint/ref/modulobyconstant.html
Examples:
Floating-point code generation (using R2024b):

Fixed-point code generation (using R2024b):
