Newsletters - MATLAB Digest
MATLAB® Add-in for Visual Studio:
Using M-files in Visual C++ Development System™
by: Ophir Herbst
Introduction
Many MATLAB applications require the usage of Visual C++ Development System™ as part of the development process. Common examples include generation of stand-alone C/C++ applications from M-files, creation and debugging of C MEX files for MATLAB, and the integration of legacy M-files in C++ applications.
The MATLAB Add-in for Visual Studio automates the task of bringing MATLAB code into Visual C++. It streamlines Visual C++ projects by setting the library and include paths, defining the constants needed, and the libraries to be included for use with compiled M-files. Furthermore, the MATLAB Add-in for Visual Studio uses the MATLAB MCC and MEX commands, eliminating the manual effort of calling them with the right parameters to compile the M- or C- files.
The MATLAB Add-in is a major new tool for MATLAB users. It makes developing hybrid MATLAB and C/C++ applications much easier, and provides tight integration between MATLAB technology and the Visual C++ environment.
With the MATLAB Add-in for Visual Studio You Can:
- Easily add M-files to an existing Visual C++ project
- Quickly create stand-alone C or C++ applications from your M-files
- Create C MEX files or M MEX files with ease
- Create shared libraries or MEX files from your M-files
- Reuse your M-files in your C/C++ applications
- Debug M-file source code rather than MATLAB Compiler generated C/C++ files
- Automate the process of editing M-files and compiling then into C/C++, all inside Visual C++
- Examine matrix data while debugging, using the Visual Matrix Viewer
- Package completed projects for distribution
Before Continuing Make Sure You Have:
- Installed MATLAB 6, the MATLAB Compiler, MATLAB Graphics Library, MATLAB Math Library and Visual C++ 5.0 or later
- Run >mbuild -setup from the dos prompt
- Run >mex -setup from the dos prompt
- Run >cd(prefdir);mccsavepath; from the MATLAB prompt
- Installed the MATLAB Add-in into Visual C++ (as per the installation instructions)
Working with MATLAB Add-in for Visual Studio
Visual MATLAB provides several components that automate tasks involved in generation and debugging of Visual C++ applications. Refer to the MATLAB Add-in installation instructions for help with component installation.
| MATLAB Project Wizard The MATLAB Project Wizard automates the creation of Visual C++ projects. It lets you select the type of application the project will generate and select the M-files for inclusion in that project. Using the MATLAB Project Wizard you should be able to easily generate a complete application that compiles and runs successfully. |
|
|
MATLAB Add-in Toolbar
|
|
|
Matrix Viewer
|
|
|
Packager Example 1: Creating a Stand-alone Application for Distribution |
![]() click to see larger image |
(c)2000 by The MathWorks, Inc. MATLAB, Simulink, Stateflow, Handle Graphics, Real-Time Workshop, and Target Language Compiler are trademarks of The MathWorks, Inc. Visual C++ and Visual Studio are registered trademarks of Microsoft Corporation in the United States and/or other countries.Other product or brand names are trademarks or registered trademarks of their respective holders.



