Using the C++ Math Library    

Stand-Alone Programs

In addition to writing M-files, there are three other ways you can call MATLAB functions: via MEX-files or via the MATLAB Engine, or by using either the MATLAB C or C++ Math Library. Any M-file, MEX file, or Engine code you write requires the entire MATLAB environment to run. However, with the MATLAB C and C++ Math libraries, you can write stand-alone (external) programs.

A stand-alone program offers several advantages:

However, there are disadvantages to stand-alone programs:

Stand-alone programs are best suited for highly numeric applications. You can, of course, incorporate calls to third-party libraries, such as the X Window System, the Microsoft Windows Graphical Device Interface or MFC, in your stand-alone programs.

You can also use the MATLAB C++ Math Library to develop one or more modules or parts of a larger program. For example, you may have a signal processing application for which you want to do algorithm development in MATLAB. To do this, you write M-files that solve your signal processing problems. Using the MATLAB C++ Math Library, you can quickly translate these M-files into C++. Then you plug the resulting C++ code into your larger program. The translation will be even faster if you use the MATLAB Compiler, which is sold separately, to automatically translate M-files to C++.

By using interpreted MATLAB for algorithm development and rapid prototyping, the MATLAB Compiler for translation to C++, the MATLAB C++ Math Library to enable the construction of external modules, and C++ for the larger program framework, you use the strengths of each.


 Memory Management Example Program: Writing Simple Functions (ex4.cpp)