Mercurial > octave-nkf
annotate examples/myset.c @ 17296:3a9efb68272d ss-3-7-6
snapshot 3.7.6
* configure.ac (OCTAVE_VERSION): Bump to 3.7.6.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 20 Aug 2013 15:17:54 -0400 |
parents | be41c30bcb44 |
children | 224e76250443 |
rev | line source |
---|---|
5864 | 1 #include "mex.h" |
2 | |
3 void | |
16867
be41c30bcb44
Re-write documentation and all examples of dynamically linked functions.
Rik <rik@octave.org>
parents:
9053
diff
changeset
|
4 mexFunction (int nlhs, mxArray* plhs[], |
be41c30bcb44
Re-write documentation and all examples of dynamically linked functions.
Rik <rik@octave.org>
parents:
9053
diff
changeset
|
5 int nrhs, const mxArray* prhs[]) |
5864 | 6 { |
7 char *str; | |
8 mxArray *v; | |
9 | |
10 if (nrhs != 2 || ! mxIsString (prhs[0])) | |
11 mexErrMsgTxt ("expects symbol name and value"); | |
12 | |
13 str = mxArrayToString (prhs[0]); | |
14 | |
15 v = mexGetArray (str, "global"); | |
16 | |
17 if (v) | |
18 { | |
19 mexPrintf ("%s is a global variable with the following value:\n", str); | |
16867
be41c30bcb44
Re-write documentation and all examples of dynamically linked functions.
Rik <rik@octave.org>
parents:
9053
diff
changeset
|
20 mexCallMATLAB (0, NULL, 1, &v, "disp"); |
5864 | 21 } |
22 | |
23 v = mexGetArray (str, "caller"); | |
24 | |
25 if (v) | |
26 { | |
27 mexPrintf ("%s is a caller variable with the following value:\n", str); | |
16867
be41c30bcb44
Re-write documentation and all examples of dynamically linked functions.
Rik <rik@octave.org>
parents:
9053
diff
changeset
|
28 mexCallMATLAB (0, NULL, 1, &v, "disp"); |
5864 | 29 } |
30 | |
31 // WARNING!! Can't do this in MATLAB! Must copy variable first. | |
32 mxSetName (prhs[1], str); | |
33 mexPutArray (prhs[1], "caller"); | |
34 } |