Are there any matlab experts here?
I would like to send to matlab from C++ an array of strings.
I'm currently using the brute force way of merging it all into one long string and then sending it via eval:
temp = "data3 =["+temp+"]";
engEvalString(ep,temp.c_str());
There has got to be a better way of doing this.
I tried the following but it didn't work.
the compile error was that temparray was char * while the right side was const char *.Code:// specify 1xN array int dims[] = {1,sf1.loadCases.size()}; mxArray *data_ml; char *temparray; data_ml = mxCreateCharArray(2,dims); temparray =(char *)mxGetData(data_ml); // loop over data and copy for(unsigned i=0; i<sf1.loadCases.size(); i++) { temparray[i] = sf1.loadCases[i].conditionNumber.c_str(); }
I'm thinking that the real source of the error is with the mxGetData command.
The matlab documentation on calling from C++ is severly lacking content.


Reply With Quote


Bookmarks