Mercurial > hg > octave-lyh
diff examples/mycell.c @ 6593:3da1f4a41455
[project @ 2007-04-27 08:08:19 by dbateman]
author | dbateman |
---|---|
date | Fri, 27 Apr 2007 08:08:19 +0000 |
parents | |
children | 2aad75fcc93a |
line wrap: on
line diff
new file mode 100644 --- /dev/null +++ b/examples/mycell.c @@ -0,0 +1,16 @@ +#include "mex.h" + +void +mexFunction (int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]) +{ + int n, i; + + if (nrhs != 1 || ! mxIsCell (prhs[0])) + mexErrMsgTxt ("expects cell"); + + n = mxGetNumberOfElements (prhs[0]); + n = (n > nlhs ? nlhs : n); + + for (i = 0; i < n; i++) + plhs[i] = mxDuplicateArray (mxGetCell (prhs[0], i)); +}