MATLAB C/C++ Graphics Library    

Compiling Applications Written as Scripts

The Compiler cannot compile applications written as scripts because scripts interact with the MATLAB base workspace, and stand-alone applications do not have access to the MATLAB base workspace.

Symptom

If you attempt to compile a script, the Compiler outputs the error message

where filename is the name of your script M-file.

Workaround

To compile an application written as a script, turn it into a MATLAB function. To do this, include the MATLAB function prototype at the top of the file. You must also find where the script depends on variables in the base workspace and declare these variables as global variables.

For example, in the following script, the variable f, set by the call to the figure function, exists in the base workspace. This variable is then passed as a parameter to the function, my_func, specified in the callback property string. Passing a workspace variable in a callback string is not supported by the MATLAB Compiler.

The following example shows this script transformed into a function.

In this code example, note the following:

    Here is the new callback function. Note how the function also declares f as a global variable.


 Using Unsupported MATLAB 6.0 Features Fixing Callback Problems: Missing Functions