MATLAB: The Model Advisor check “Identify questionable operations for strict single-precision design” fails, having a Stateflow chart in the model

checkconversiondoubleprecisionSimulink Checksinglestateflow

Why the Model Advisor check "Identify questionable operations for strict single-precision design" fails, having a Stateflow chart in the model?
All variables are converted using single precision or type casted to single.

Best Answer

  • The solver is a variable step solver.
    The check finds double precision in the following:
    untitled/Chart/start_state
    untitled/Chart
    untitled/Chart/transition(#1368)
    untitled/Chart/start_state
    untitled/Chart
    untitled/Chart/transition(#1368)
    untitled/Chart/start_state
    untitled/Chart
    untitled/Chart/start_state
    untitled/Chart/transition(#1366)
    untitled/Chart/init_state
    untitled/Chart
    This is expected behavior due to variable-step solver. You can see some double variables in generated code after you set system target file to rsim.tlc
    If you set fixed-step solver, then the generated code does not have double data type, so the double-precision check will be passed.
    Another issue with the same error:
    I have something defined like the following, but I get also an error?
    [after(tFALL+single(2.5),sec) && Z3IN==1]
    Workaround for this issue is to create local data with single data type and use it instead of numeric value (e.g. [after(tFALL+LocalData,sec) && Z3IN==1])