User`s guide

5 Compiler Commands
Running this script M-file from a MATLAB session creates variables m and t
in your MATLAB w orkspace browser.
MATLAB Compiler cannot compile
houdini.m because it is a script. Convert
this script M -file into a function M-file by simply adding a
function header
line.
function houdini(sz)
m = magic(sz); % Assign magic square to m.
t = m .^ 3; % Cube each element of m.
disp(t) % Display the value of t.
MATLAB Compiler can now compile ho udin i.m. However, because this
makes
houdini a function, running the function no longer creates variables
m and t in the MATLAB workspace browser. If it is important to have m
and t accessible from the MATLAB workspace browser, you can change the
beginning of the function to
function [m,t] = houdini(sz)
The function now returns the values of m and t to its caller.
Including Script Files in Deployed Applications
Compiled applicat ions consis t of two layers of M -fil es. The top layer i s the
interface layer and consists of those functions that are directly accessible
from C or C++.
In standalone applications, the interface layer consists of only the main
M-file. In libraries, the interface layer consists of the M-files specified on
the
mcc command line.
The second layer of M-files in compiled applications includes those M-files
that are called by the functions in the top layer. You can include scripts in the
second layer, but not in the t op layer.
For example, you could produce an application from the
houdini.m script
M-file by writing a new M-function that calls the script, rather than
converting the script into a function.
5-20