How to protect MEX file from empty inputs
1 view (last 30 days)
Show older comments
Hello,
I have a function of the form:
void nodal_connectivity(double *links, int maxconnections,
int size_rn, int size_links,
double *node_connectivity);
void mexFunction(int nlhs, mxArray *plhs[],
int nrhs, const mxArray *prhs[])
{
double *links;
double *node_connectivity;
int maxconnections,size_rn,size_links;
if (nrhs!=4) mexErrMsgTxt("4 inputs required: links and maxconnections, size_rn, size_links!");
if (nlhs!=1) mexErrMsgTxt("Only one output given, node_connectivity");
links=mxGetPr(prhs[0]);
maxconnections=mxGetScalar(prhs[1]);
size_rn=mxGetScalar(prhs[2]);
size_links=mxGetScalar(prhs[3]);
plhs[0]=mxCreateDoubleMatrix(size_rn*maxconnections,1,mxREAL);
node_connectivity=mxGetPr(plhs[0]);
nodal_connectivity(links,maxconnections,size_rn,size_links,node_connectivity);
}
When I call the function, I would like to protect Matlab if the "links" array is empty. This may occur in my Matlab program. I know that I can simply put a not(isempty(links)) condition prior to execution of the MEX file, but to make it a bit more robust (i.e. in case I forget), is there a test in mxFunction that tests for empty inputs and if so, exits with a given return value for example?
Thank you!
F
0 Comments
Answers (1)
See Also
Categories
Find more on Write C Functions Callable from MATLAB (MEX Files) in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!