Objective: To get through the channel between MATLAB and VC, realize the VC program using MATLAB, and VC call MATLAB program.
On the blog to achieve the Matlab of the M file compiled into A/C + + file, exe application. This implementation of MATLAB compiler CPP code.
#include "mex.h"
void mexfunction (int nlhs, Mxarray *plhs[], int nrhs, const mxarray *prhs[])
{
int i;
I=mxgetscalar (Prhs[0]);
if (i==1)
mexprintf ("hello,world!\n");
else
mexprintf ("Hello everyone.") \ n ");
}
Above is a simple C + + code, saved into Helloworld.cpp. Briefly explain:
is a MEX interface subroutine, the Access program is the interface with MATLAB, to achieve two different memory space communication.
In the MATLAB command line:
Input Mex Helloworld.cpp, compilation successful.
Results:
Note: You must set up the compiler before calling Mex, the compiler settings are very simple, see my last blog, do not say more.