Beruflich Dokumente
Kultur Dokumente
JCT
II. Requirements
1. Matlab must be installed on the pc on which the program is being compiled.
2. The Microsoft Visual C++ IDE must be used. It is the only IDE tested.
#include <matlab.h>
4. The path to matlab.h must be included using “Tools, Options, Directories, Include
Files” in the IDE. A typical path to matlab.h is c : \matlab6p5\extern\include.
5. The path to the precompiled matlab libraries must be included using “Tools, Op-
tions, Directories, Library Files” in the IDE. A typical path to the library files is
c : \matlab6p5\extern\lib\win32\microsoft\msvc50.
6. The path to MatlabEng.h (described in the next section) must be included using “Tools,
Options, Directories, Include Files” in the IDE.
If any other precompiled libraries and corresponding header files are required, tabei.h for
example, then the paths to the header and libraries must also be defined for proper linking
of the compiled source.
1
IV. C code sample
To use the MatlabEng class in your code, include the line
#include “MatlabEng.h”
in your c or c++ source that is calling Matlab and refer to the following sample...
CMatlabEng matlab;
matlab.Open(NULL);
matlab.SetVisible(TRUE);
matlab.EvalString(”cd path to an m file on local pc;”);
matlab.EvalString(”matlab m file(argument);”);
getch(); //remember to include conio.h
matlab.Close();
The code snippet above is used to call a user defined (through creation of an m file)
function. It is important to change the Matlab working folder to the location of the m file
prior to attempting execution. If the argument is also a filename, it should reside in the
current Matlab working folder. No other tests were done to determine if files could be read
from more than one directory. Note that not only can your own routines be called, but
built-in Matlab functions can also be used. Since data from the c code can be written to the
Matlab workspace using the wrapper class PutVariable call, native Matlab functions can be
used to operate on your data.
Caveat—You may find that even though your source compiles and links without error,
you receive messages like
when you execute yor code. This message can be generated by the lapack.dll Matlab dynamic