User`s guide

Interfacing M-Co de to C/C++ Code
%#external
persistent t;
if (isempty(t))
t=0;
end
t = t + 0.05;
y = sin(t);
When this file is compi led , MATLA B Compiler creates the additional
header file
collect_one_external.h, which contains the interface between
MATLAB Compilergenerated code and your code. In this example, it would
contain:
extern bool collect_one(int nlhs, mxArra y *plhs[ ],
int nrhs, mxArray *prhs[]);
Note Thereturntypehaschangedfromvoid to bool in MATLAB C ompiler
post-R13.
It is recommended that you include this header file when defining the
function. This function could be implemented in this C file,
measure.c,using
the
measure_from_device() function.
#include "collect_one_ exte rnal.h"
#include <math.h>
extern double measure_from_dev ice(void);
bool collect_one(int nlhs, mxArray *plhs[ ],
int nrhs, mxArray *prhs[])
{
plhs[0] = mxCreateDoubleMatrix (1,1,mxREAL);
*(mxGetPr(plhs[0])) = measure_ from_device();
}
double measure_from_de vice (void)
{
5-15