Programming and Data Types    

Private Functions

Private functions are functions that reside in subdirectories with the special name private. They are visible only to functions in the parent directory. For example, assume the directory newmath is on the MATLAB search path. A subdirectory of newmath called private can contain functions that only the functions in newmath can call. Because private functions are invisible outside of the parent directory, they can use the same names as functions in other directories. This is useful if you want to create your own version of a particular function while retaining the original in another directory. Because MATLAB looks for private functions before standard M-file functions, it will find a private function named test.m before a nonprivate M-file named test.m.

You can create your own private directories simply by creating subdirectories called private using the standard procedures for creating directories or folders on your computer. Do not place these private directories on your path.


  Subfunctions Variables