annotate examples/code/myset.c @ 19225:c8240a60dd01

Add penny.mat to build system. * examples/data/penny.mat: New example data file. * examples/data/Makefile.am: Automake file for new directory of example data files. * examples/Makefile.am: Change to be just a pass-through to the subdirectories code/ and data/. * examples/@FIRfilter/FIRfilter.m, examples/@FIRfilter/FIRfilter_aggregation.m, examples/@FIRfilter/display.m, examples/@FIRfilter/module.mk, examples/@FIRfilter/subsasgn.m, examples/@FIRfilter/subsref.m, examples/@polynomial/display.m, examples/@polynomial/double.m, examples/@polynomial/end.m, examples/@polynomial/get.m, examples/@polynomial/module.mk, examples/@polynomial/mtimes.m, examples/@polynomial/numel.m, examples/@polynomial/plot.m, examples/@polynomial/polynomial.m, examples/@polynomial/polynomial_superiorto.m, examples/@polynomial/polyval.m, examples/@polynomial/roots.m, examples/@polynomial/set.m, examples/@polynomial/subsasgn.m, examples/@polynomial/subsref.m, examples/COPYING, examples/addtwomatrices.cc, examples/celldemo.cc, examples/embedded.cc, examples/fortrandemo.cc, examples/fortransub.f, examples/funcdemo.cc, examples/globaldemo.cc, examples/helloworld.cc, examples/make_int.cc, examples/mex_demo.c, examples/mycell.c, examples/myfeval.c, examples/myfevalf.f, examples/myfunc.c, examples/myhello.c, examples/mypow2.c, examples/myprop.c, examples/myset.c, examples/mysparse.c, examples/mystring.c, examples/mystruct.c, examples/oct_demo.cc, examples/oregonator.cc, examples/oregonator.m, examples/paramdemo.cc, examples/standalone.cc, examples/standalonebuiltin.cc, examples/stringdemo.cc, examples/structdemo.cc, examples/unwinddemo.cc: Move current example files to examples/code/ directory. * configure.ac: Add Makefiles in examples/code and examples/data directories. * build-aux/common.mk: Define octdatadir variable. * doc/interpreter/Makefile.am: Change location of External Code Interface examples to examples/code directory. * doc/interpreter/munge-texi.pl: Expand EXAMPLEFILE macro to examples/code directory.
author Rik <rik@octave.org>
date Tue, 19 Aug 2014 14:32:44 -0700
parents examples/myset.c@224e76250443
children 5c42ff6f0eb1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
1 #include "mex.h"
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
2
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
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
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
6 {
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
7 char *str;
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
8 mxArray *v;
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
9
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
10 if (nrhs != 2 || ! mxIsString (prhs[0]))
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
11 mexErrMsgTxt ("expects symbol name and value");
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
12
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
13 str = mxArrayToString (prhs[0]);
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
14
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
15 v = mexGetArray (str, "global");
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
16
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
17 if (v)
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
18 {
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
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
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
21 }
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
22
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
23 v = mexGetArray (str, "caller");
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
24
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
25 if (v)
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
26 {
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
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
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
29 }
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
30
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
31 // WARNING!! Can't do this in MATLAB! Must copy variable first.
17791
224e76250443 Use GNU style coding conventions for code in examples/
Rik <rik@octave.org>
parents: 16867
diff changeset
32 mxSetName (prhs[1], str);
5864
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
33 mexPutArray (prhs[1], "caller");
e884ab4f29ee [project @ 2006-06-22 00:57:27 by jwe]
jwe
parents:
diff changeset
34 }