MATLAB Answers

Recompiling an S function, altered results

1 view (last 30 days)
John Robinson
John Robinson on 9 Aug 2011
Hello,
I'm trying to restore an old Simulink S-function. The function was last compiled ~2004, and I am trying to recompile it now. I've successfully compiled the C-code using both MS Visual C++ 2008 Express and GCC (via MinGW), and was unsuccessful compiling the code using LCC or Open WATCOM. MATLAB version R2009a.
Currently, when the code is run and compared against the results from the "Old" (2004) mex functions, the results differ. It appears as if a very small initial error propagates. I am using the same conditions for the tests, same version of MATLAB, but I still get small, but distinctively different, changes in the results. From the 2 compilers which I have been successful compiling (GCC and MS Visual C++), I get identical results. I think the code may have been originally compiled with the Intel compiler, which is not available to me. Since the other compilers which I used have identical results, I don't think this is the issue. Also, I have tested in R2009a and R2007b.
Any ideas what could be causing the differences in results? Same source code, same initial conditions, different simulation results.
Thanks a lot for any ideas, I know this isn't a ton to go on.
JR
  3 Comments
John Robinson
John Robinson on 9 Aug 2011
No, everything thus far has been 32-bit. Thanks for the idea though.

Sign in to comment.

Accepted Answer

MarkB
MarkB on 15 Aug 2011
I recommend checking to see if there are any differences in support for floating-point operations. Specifically, check to see if things like math.h have support for both "float" and "double", or just "double" (this difference comes up with ANSI vs ISO implementations of C).

More Answers (0)

Community Treasure Hunt

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

Start Hunting!