MATLAB gives different results when compiled vs interactive

14 views (last 30 days)
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.

Accepted Answer

Andreas Goser
Andreas Goser on 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".

More Answers (2)

Image Analyst
Image Analyst on 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 on 14 Jan 2012
The two situations are not defined to have the same floating point rounding behavior.

Categories

Find more on Programming 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!