From: Michel on
Good morning Matlabbers!

I have recently started working with Matlab. To get familiar with the Matlab Engine and its functions I have created a simple c++ programm, which puts some variables into the engine and evaluates some strings. Everythings works perfectly.

Afterwards I have started to add these functions to my actual programm:

GraspController::GraspController()
{
enabled=false;
//load Matlab Engine
ep = engOpen("");
if(ep=NULL){
printf("error: Matlab Engine not found\n");
}
}


void GraspController::UpdateGraspController(std::vector<CCharge> c, int ccount, std::vector<CCharge> a, int acount)
{...}

void GraspController::ExportPointset(){

mxArray *c = mxCreateDoubleMatrix(noofrepellant,3,mxREAL);
mxArray *cn = mxCreateDoubleMatrix(noofrepellant,3,mxREAL);
mxArray *a = mxCreateDoubleMatrix(noofattractor,3,mxREAL);
mxArray *an = mxCreateDoubleMatrix(noofattractor,3,mxREAL);

writeToMxArray(c,cn,repellant,noofrepellant);
writeToMxArray(a,an,attractor,noofattractor);

engPutVariable(ep, "c", c);
engPutVariable(ep, "cn", cn);
engPutVariable(ep, "xa", a);
}

void GraspController::writeToMxArray(mxArray* c,mxArray* cn,std::vector<CCharge> data, int size)
{...}
void GraspController::createGraspAffordance()
{
engEvalString(ep, "filterpipe.parAngle = 0.5");
engEvalString(ep, "filterpipe.minSize = 0.001");
engEvalString(ep, "filterpipe.mutVisArea = 0.0005");
engEvalString(ep, "filterpipe.distLimit = [0.0 0.03]");
engEvalString(ep, "G=CreateGraspAffordances(c,cn,filterpipe);" );
//engGetVariable(ep, G);
}

A little explanation: The UpdateGraspContoller function is periodically called from an other class with a current set of data. Then the data is written to mxArrays, put into the engine and the desired calculations are made.

Except of starting the engine, matlab does not do anything. The console is open and working, but no variables are put into the engine and no calculations are made. I have tested all commands in the test programm and they worked. I have also checked that the c++ commands are actually executed, which is the case.

Does anyone have an idea what the reason for this behavior of matlab could be. Any help would be much appreciated.

Thanks!
Michel