External Interfaces/API | ![]() ![]() |
Compiling and Linking MAT-File Programs
This section describes the steps required to compile and link MAT-file programs on UNIX and Windows systems. It begins by looking at a special consideration for compilers that do not mask floating-point exceptions. Topics covered are:
Masking Floating Point Exceptions
Certain mathematical operations can result in nonfinite values. For example, division by zero results in the nonfinite IEEE value, inf
. A floating-point exception occurs when such an operation is performed. Because MATLAB uses an IEEE model that supports nonfinite values such as inf
and NaN
, MATLAB disables, or masks, floating-point exceptions.
Some compilers do not mask floating-point exceptions by default. This causes MAT-file applications built with such compilers to terminate when a floating-point exception occurs. Consequently, you need to take special precautions when using these compilers to mask floating-point exceptions so that your MAT-file application will perform properly.
The platforms and compilers on which you should mask floating-point exceptions are
To mask floating-point exceptions on the DEC Alpha platform, use the -fpe3
compile flag. For example,
f77 -fpe3
To mask floating-point exceptions when using the Borland C++ compiler on the Windows platform, you must add some code to your program. Include the following at the beginning of your main()
or WinMain()
function, before any calls to MATLAB API functions.
#include <float.h> . . . _control87(MCW_EM,MCW_EM); . . .
![]() | Reading a MAT-File in Fortran | Compiling and Linking on UNIX | ![]() |