Getting MATLAB variable (string) from C

Posted by Hamming on Stack Overflow See other posts from Stack Overflow or by Hamming
Published on 2010-04-22T11:29:54Z Indexed on 2010/04/22 11:33 UTC
Read the original article Hit count: 146

Filed under:
|
|

Hi! I'm writing a small C application that launchs a Matlab script (.m file). I need to exchange some variables and I don't know how to get an array of chars that exists in Matlab.

I'm doing something like this:

enter code here
result = engGetVariable(ep,"X");
if (!result)
    {
    printf ("Error...");
            exit -1;
    }

int n = mxGetN(result);

    char *varx = NULL;
    memcpy(varx, mxGetData(result),n*sizeof(char));

It doesn't work. Does someone know how to get a Matlab string in C? I've read Matlab documentation about engGetVariable() and the provided example but any of this things clarify me.

© Stack Overflow or respective owner

Related posts about matlab

Related posts about c