Online posts are how to add VC + + data into Matlab, and VC + + calls the data in MATLAB almost no, record a little something again
Configure the programming environment, this article environment is: vs2012+matlab2012b.
The first thing to understand is the MATLAB Engine API function
Next paste the code and effect:
void Test2 () {Engine *ep;if (!) ( EP = Engopen (NULL))) {cout<< "can ' t start matlab engine" <<endl;//messagebox ((HWND) NULL, "can ' t start matlab Engine "," Matlab Draw ", MB_OK);//return 0;} Apply the y array in the MATLAB space and assign the value engevalstring (EP, "y=0:1:511;"); /engine data type Mxarray *gistarry1=null;//gets the pointer of matlab Space y gistarry1=enggetvariable (EP, "Y"); cout<<endl;// Gets the number of dimensions of y Cout<<mxgetn (gistarry1) <<endl;cout<<mxgetm (gistarry1) <<endl;//Gets the real pointer of y double *BB = MXGETPR (Gistarry1); Output data for (int i=0;i<mxgetn (gistarry1), i++) for (int J=0;j<mxgetm (gistarry1); j + +) {cout<<bb[i]<< " "if (i%15==0) {Cout<<endl;}} Drawing Engevalstring (EP, "X=0:0.01:5.11;plot (x, y);"); Engevalstring (EP, "title (' Matlab Drawing ');"); Engevalstring (EP, "Xlabel (' X ');"); Engevalstring (EP, "Ylabel (' Y ');"); Cout<<endl;system ("pause"); Engclose (EP);//return 0;}
Operating effects such as:
Summary: 1. Data types to be unified