Compiled Simulink model giving different results
Mostrar comentarios más antiguos
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?
Respuesta aceptada
Más respuestas (2)
Andreas Goser
el 16 de Oct. de 2013
0 votos
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 comentarios
Guy Rouleau
el 17 de Oct. de 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
el 18 de Oct. de 2013
Categorías
Más información sobre Simulink Coder en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!