1 #include "mex.h"
2 
3 void
mexFunction(int nlhs,mxArray * plhs[],int nrhs,const mxArray * prhs[])4 mexFunction (int nlhs, mxArray *plhs[],
5              int nrhs, const mxArray *prhs[])
6 {
7   double handle;
8   char property[256];
9 
10   if (nrhs < 2 || nrhs > 3)
11     mexErrMsgTxt ("incorrect number of arguments");
12   if (! mxIsDouble (prhs[0]))
13     mexErrMsgTxt ("handle must be a double scalar");
14   if (! mxIsChar (prhs[1]))
15     mexErrMsgTxt ("property must be a string");
16 
17   handle = mxGetScalar (prhs[0]);
18   mxGetString (prhs[1], property, 256);
19   plhs[0] = mxDuplicateArray (mexGet (handle, property));
20 
21   if (nrhs == 3)
22     if (mexSet (handle, property, mxDuplicateArray (prhs[2])))
23       mexErrMsgTxt ("failed to set property");
24 }
25