Compiled Simulink model giving different results
Show older comments
I have a simulink model (.slx) that I am trying to compile and run in Visual Studio. I'm finding that my results are different than the output of the model in simulink. I've tried compiling under C and C++ with identical results.
For example the first few simulink results are 100 97.1696536696777 94.5212838899871 92.0431905150397 89.7244256574844 87.5547453221953
and visual studio: 97.87 95.18 92.66 90.30 88.09 86.03
If I have a 2 minute simulation with .04 time step my Visual Studio results appear to skip the first step and then be shifted left by .03.
Any ideas?
Accepted Answer
More Answers (2)
Andreas Goser
on 16 Oct 2013
0 votes
Beside there are multiple ways to "compile and run a model", this is really something where you should contact Technical Support for and include your example.
2 Comments
Guy Rouleau
on 17 Oct 2013
Three steps... looks like you are using the ode3 solver.
If your model uses ode1, results should match, but accuracy will change.
If you change your model to be fully discrete, results should match.
Inserting a Unit Delay, Rate Transition, or another block that makes your output discrete can make the results match because discrete blocks only execute Output once and Update once.
As you can figure out, those options are changing the simulation so that it generates code that will return identical results. To have more control over the generated control, you need Embedded Coder.
I want to repeat it again to be sure it is clear... the results using you get using GRT are not wrong... they are just extracted from the simulation loop at a different time.
Matt
on 18 Oct 2013
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!