Call methods on MATLAB objects instantiated in a CMEX function

조회 수: 2 (최근 30일)
Rob
Rob 2014년 6월 3일
답변: Rob 2014년 6월 3일
Hi,
I've got a CMEX function in which I call a MATLAB function to get a MATLAB object like this:
mxArray *plhs[1];
mexCallMATLAB(1, plhs, 0, NULL, "getAnObject");
Now, I want to call a method on this object. In MATLAB, I would have done it like this:
obj = getAnObject;
obj.aMethod();
How can I solve this in a CMEX function?
P.S.: getAnObject itself is a compiled mex file.

채택된 답변

Rob
Rob 2014년 6월 3일
I found the solution here:
An alternative way of calling a method on a MATLAB object is this:
returnedValue = methodName(object,args,...)
So, transferred to my CMEX file:
mxArray *plhs[1];
mexCallMATLAB(1, plhs, 0, NULL, "getAnObject");
mxArray *params[2];
params[0] = plhs[0];
params[1] = mxCreateDoubleScalar(12);
mexCallMATLAB(0, NULL, 2, params, "aFunction");
Have a nice day!

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB Compiler에 대해 자세히 알아보기

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by