Embedded Coder - difference in results between the original model and generated C code
Show older comments
Hello.
I created a simple model in SIMULINK (plese see the attachment and the picture below). I used ODE 5 (Dortmand-Prince) fixed step solver with step size 0.01 s.

Then I performed a C code generation using Embedded Coder. Later I used Software-in-the-Loop to investigate the numerical equivalency/similarity between the outputs from original SIMULINK model and generated C code. Especially I am interested in "Output 4" and "sin" function (they are indicated using blue marks). From the verification stage I concluded that there exists a numerical diferences between both results. The obtained results are presented below (blue arrows indicates these mismatches). The model operates on "single" numeric type number. In that way in the generated C code function "sinf" is used. My goal is to minimize these differences. There is no possibility to use "double" because the code will be implemented on ARM Cortex M4 target hardware. I think that the resulting code should give exactly the same results as the original model. Is it possible to drive these errors to 0? I am not sure what is wrong with the code generator settings. Maybe this is the typical output in such a case?

Kind regards,
Mariusz
Accepted Answer
More Answers (0)
Categories
Find more on Simulink Coder in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!