MATLAB: “Error floating constant is out of range” during code generation

simulink

During code generation, this particular error occurs when there is a function block or any computing block that expects a Double (input or output) but the compiler is treating data types as Single.
Error floating constant is out of range during code generation

Best Answer

This issue can be resolved by using a "Data Type Conversion" block before and after the computing block in question. Add a conversion block to convert the input from Double to Single, and to convert the output from Single to Double.
Related Question