MATLAB Compiler | ![]() ![]() |
Compiling Private and Method Functions
Private functions are functions that reside in subdirectories with the special name private
, and are visible only to functions in the parent directory. Since private functions are invisible outside of the parent directory, they can use the same names as functions in other directories. Because MATLAB looks for private functions before standard M-file functions, it will find a private function before a nonprivate one.
Method functions are implementations specific to a particular MATLAB type or user-defined object. Method functions are only invoked when the argument list contains an object of the correct class.
In order to compile a method function, you must specify the name of the method along with the classname so that the Compiler can differentiate the method function from a nonmethod (normal) function.
Method directories can contain private directories. Private functions are found only when executing a method from the parent method directory. Taking all of this into account, the Compiler command line needs to be able to differentiate between these various functions that have the same name. A file called foo.m
that contains a function called foo
can appear in all of these locations at the same time. The conventions used on the Compiler command line are documented in this table.
This table lists the functions you can specify on the command line and their corresponding function and filenames.
For private functions, the name given in the table above may be ambiguous. The MATLAB Compiler generates a warning when it cannot distinguish which private function to use. For example, given these two foo.m
private functions and their locations
the Compiler searches up only one level and determines the path to the file as
Since it is ambiguous which foo.m
you are requesting, it generates the warning
Warning: The specified private directory is not unique. Both /Z/X/private and /Y/X/private are found on the path for this private directory.
![]() | Generated Code | The Generated Header Files | ![]() |