How to call mxArray with varargin in C; mxCreateCellMatrix and mxSetCell?
Show older comments
Compile/build works, but I only get the first argument into matlab function and then program (.exe) crashes. Can I use the mxCreateCellMatrix as input to varargin?
int wmlfNor(char* filenameinp, char* filenameana, char* filenamecsv){
int nargout=1;
mxArray *pfinp;
mxArray *pfana;
mxArray *pfcsv;
mxArray *pvarargin;
mxArray *out=NULL;
int returnval=isMCRrunning();
if(!returnval)
return returnval;
pfinp=mxCreateString(filenameinp);
pfana=mxCreateString(filenameana);
pfcsv=mxCreateString(filenamecsv);
pvarargin=mxCreateCellMatrix(3,1);
mxSetCell(pvarargin,0,pfinp);
mxSetCell(pvarargin,1,pfana);
mxSetCell(pvarargin,2,pfcsv);
%Call to my Matlab function
returnval=mlfNor(nargout,&out, pvarargin);
mxDestroyArray(pfinp);
mxDestroyArray(pfana);
mxDestroyArray(pfcsv);
mxDestroyArray(pvarargin);
mxDestroyArray(out);
return returnval;
}
Accepted Answer
More Answers (0)
Categories
Find more on Write C Functions Callable from MATLAB (MEX Files) in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!