User`s guide

5 Compiler Commands
t = t + 0.05;
y = sin(t);
The next step is to replace the implementation of the collect_one function
with a C impleme ntatio n that provides the correct value from the device each
time it is requested. This is accompli sh ed by using th e
%#external pragma.
The
%#external pragma inform s MATLAB Compi ler that the f unction w i ll be
hand written and will not be generated from the M -code. This pragma affects
only the single functi on in which it appe ars. Any M-function may contain th is
pragma (local, global, private, or method). When using this pragma, MATLAB
Compiler w ill generate an additional header file called
fcn_external.h,
where
fcn is the name of the initial M-function containing the %#external
pragma. This heade r file will contain the extern declaration of the function
that you must provide. This function must conform to the same interface as
code generated by MATLAB Compiler.
Note If you compile a program that contains the %#e xter nal pragma, you
must explicit ly pa ss each file that contain s thi s pragma on the
mcc com m and
line.
MATLAB Compiler will generate the interface for any functions that contain
the
%#external pragma into a separate file called fcn_external .h.TheC
or C++ f il e generated b y MATLAB Com piler wil l in clude this header file to
get the declaration of the function being provided.
In this example, place the pragma in the
collect_one local function.
function collect
y = zeros(1, 100); % p reallocate the matrix
for i = 1:100
y(i) = collect_one;
end
disp (y)
function y = collect_one
5-14