MATLAB gives different results when compiled vs interactive

11 vues (au cours des 30 derniers jours)
Peter Tenenbaum
Peter Tenenbaum le 13 Jan 2012
Here at the Kepler SOC, we have observed numerous examples of situations in which our MATLAB applications produce different results depending on whether the application is run interactively or compiled via the MATLAB compiler. This can be the case when the MATLAB code in both instances is identical and when the two tests are run on the same workstation (64 bit Linux and R2010b, FYI). Can anyone explain why this should happen, and what we can do to minimize the circumstances under which it does happen? Thanks in advance.

Réponse acceptée

Andreas Goser
Andreas Goser le 14 Jan 2012
I am collecting reasons for those effects and like to link it to this post, although it is certainly a different issue.
While I agree with the other answers so far, I still understand the user's perspective and question how to minimize this occurence. First, I like to distinguish between very small differnces, that are not changes a conclusion from a computation and differences, that really lead to complete results.
In the practical life, I would debug such applications in a way to identifies the main contributor for the differences in the code. Often, this is just a single line in a loop where small numerical differences add up. In most cases, there are better algorithms that are "numerically safe".

Plus de réponses (2)

Image Analyst
Image Analyst le 14 Jan 2012
There could be a variety of reasons, for example data files not being where you thought they were because you didn't use the complete path and then creating default data values instead, or any number of other reasons. Even when run on the same workstation, the compiled app and the m-file do not run in the same folder, even though you might think they do (it's a long story...), so that might cause some differences.

Walter Roberson
Walter Roberson le 14 Jan 2012
The two situations are not defined to have the same floating point rounding behavior.

Catégories

En savoir plus sur Programming dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by