Hello, Below is my code that attempts to pass a char array to MATLAB from C++ but can't. Can some one please help.
#include <yvals.h>#if (_MSC_VER >= 1600)#define __STDC_UTF_16__#endif#include "mex.h"#include <stdlib.h>#include <vector>#include "engine.h"#include <iostream>#include <windows.h>#include <ctime>#include <string>using namespace std;int main(){ Engine *ep; if (!(ep = engOpen(NULL))) { cout << "Can't open Matlab\n\n" << endl; return -1; } char test[3][3] = {"11","12","13"}; int dims[2]={3,10}; mxArray *in = mxCreateCharArray(2, (const mwSize *)dims); memcpy(mxGetPr(in), test, 3*sizeof(char)); engPutVariable(ep, "test", in); // Place the variable NS into the MATLAB workspace}
Best Answer