Mercurial > octave
annotate examples/myfeval.c @ 18479:85d31344fb23 stable rc-3-8-1-2
3.8.1 release candidate 2
* configure.ac (OCTAVE_VERSION): Bump to 3.8.1-rc2.
(OCTAVE_MINOR_VERSION): Bump to 1-rc2.
(OCTAVE_RELEASE_DATE): Set to 2014-02-14.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 17 Feb 2014 02:20:39 -0500 |
parents | d1e16bdb3958 |
children |
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:
9932
diff
changeset
|
4 mexFunction (int nlhs, mxArray* plhs[], |
be41c30bcb44
Re-write documentation and all examples of dynamically linked functions.
Rik <rik@octave.org>
parents:
9932
diff
changeset
|
5 int nrhs, const mxArray* prhs[]) |
5864 | 6 { |
7 char *str; | |
8 | |
18367
d1e16bdb3958
myfeval.c: Fix segfault in mex example code.
Rik <rik@octave.org>
parents:
17791
diff
changeset
|
9 mexPrintf ("Starting file myfeval.mex\n"); |
5864 | 10 |
16867
be41c30bcb44
Re-write documentation and all examples of dynamically linked functions.
Rik <rik@octave.org>
parents:
9932
diff
changeset
|
11 mexPrintf ("I have %d inputs and %d outputs\n", nrhs, nlhs); |
5864 | 12 |
17791
224e76250443
Use GNU style coding conventions for code in examples/
Rik <rik@octave.org>
parents:
16867
diff
changeset
|
13 if (nrhs < 1 || ! mxIsString (prhs[0])) |
16867
be41c30bcb44
Re-write documentation and all examples of dynamically linked functions.
Rik <rik@octave.org>
parents:
9932
diff
changeset
|
14 mexErrMsgTxt ("ARG1 must be a function name"); |
5864 | 15 |
16 str = mxArrayToString (prhs[0]); | |
17 | |
7081 | 18 mexPrintf ("I'm going to call the function %s\n", str); |
5864 | 19 |
18367
d1e16bdb3958
myfeval.c: Fix segfault in mex example code.
Rik <rik@octave.org>
parents:
17791
diff
changeset
|
20 if (nlhs == 0) |
d1e16bdb3958
myfeval.c: Fix segfault in mex example code.
Rik <rik@octave.org>
parents:
17791
diff
changeset
|
21 nlhs = 1; // Octave's automatic 'ans' variable |
d1e16bdb3958
myfeval.c: Fix segfault in mex example code.
Rik <rik@octave.org>
parents:
17791
diff
changeset
|
22 |
d1e16bdb3958
myfeval.c: Fix segfault in mex example code.
Rik <rik@octave.org>
parents:
17791
diff
changeset
|
23 /* Cast prhs just to get rid of 'const' qualifier and stop compile warning */ |
d1e16bdb3958
myfeval.c: Fix segfault in mex example code.
Rik <rik@octave.org>
parents:
17791
diff
changeset
|
24 mexCallMATLAB (nlhs, plhs, nrhs-1, (mxArray**)prhs+1, str); |
5864 | 25 |
26 mxFree (str); | |
27 } |