5864
|
1 #include "mex.h" |
|
2 |
|
3 void |
|
4 mexFunction (int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]) |
|
5 { |
|
6 char *str; |
|
7 mxArray *v; |
|
8 |
|
9 if (nrhs != 2 || ! mxIsString (prhs[0])) |
|
10 mexErrMsgTxt ("expects symbol name and value"); |
|
11 |
|
12 str = mxArrayToString (prhs[0]); |
|
13 |
|
14 v = mexGetArray (str, "global"); |
|
15 |
|
16 if (v) |
|
17 { |
|
18 mexPrintf ("%s is a global variable with the following value:\n", str); |
|
19 mexCallMATLAB (0, 0, 1, &v, "disp"); |
|
20 } |
|
21 |
|
22 v = mexGetArray (str, "caller"); |
|
23 |
|
24 if (v) |
|
25 { |
|
26 mexPrintf ("%s is a caller variable with the following value:\n", str); |
|
27 mexCallMATLAB (0, 0, 1, &v, "disp"); |
|
28 } |
|
29 |
|
30 // WARNING!! Can't do this in MATLAB! Must copy variable first. |
|
31 mxSetName (prhs[1], str); |
|
32 mexPutArray (prhs[1], "caller"); |
|
33 } |