I have a Matlab MEX file that I want to call in my CPP program. I have two problems! first, when I call it via the mexCallMATLAB function, I get the following exception error:
"Unhandled exception at 0x00000000 in testmex.exe: 0xC0000005: Access violation at location 0x0000000000000000."
how can I fix it?
Second, how can I set the MEX file address in my visual studio project?
code :
void main()
{
    
    mxArray* plhs[1];
    mxArray* prhs[1];
    double *plhs_p,  *prhs_p;
    prhs[0] = mxCreateDoubleMatrix(1, 1, mxREAL);
    prhs_p = mxGetPr(prhs[0]);
    plhs[0] = mxCreateDoubleMatrix(1, 1, mxREAL);
    cout << "enter number:" << endl;
    cin >> prhs_p[0];
    mexCallMATLAB(1, plhs, 1, prhs, "test_mex");
    mxDestroyArray(prhs[0]);
    plhs_p = mxGetPr(plhs[0]);
    cout << prhs_p[0] << "^2:" << endl;
        cout << plhs_p[0] << endl;
        mxDestroyArray(plhs[0]);
}
User contributions licensed under CC BY-SA 3.0