User`s guide

5 Controlling Code Generation
5-4
foo M-File
function [a, b] = foo(x, y)
if nargout == 0
elseif nargout == 1
a = x;
elseif nargout == 2
a = x;
b = y;
end
fun M-File
function a = fun(b)
a(1) = b(1) .* b(1);
a(2) = b(1) + b(2);
a(3) = b(2) / 4;
sample M-File
function y = sample( varargin )
varargin{:}
y = 0;
Generated Code
This chapter investigates the generated header fil es, interface functions, and
wrapper functions for the C MEX, stand-alone C and C++ t argets, and C and
C++ libraries.
When you use the MATLAB Compiler to compile an M-file, it generates these
files:
C or C++ code, depending on your target language (
-L) specification
Header file
Wrapper file, depending on the
-W option
The C or C++ code that is generated by the Compiler and the header file are
independent of the final target type and target platform. That is, the C or C++
code and header file are identical no matter what the desired final output. The
wrapperfileprovidesthe code necessaryt o support theoutputexecutabletype.
So, the wrapper file is different for each execut able type.