Programming and Data Types    

Private Methods

Private methods can be called only by other methods of their class. You define private methods by placing the associated M-files in a private subdirectory of the @class_name directory. In the example,

the method update_obj has scope only within the class_name class. This means that update_obj can be called by any method that is defined in the @class_name directory, but it cannot be called from the MATLAB command line or by methods outside of the class directory, including parent methods.

Private methods and private functions differ in that private methods (in fact all methods) have an object as one of their input arguments and private functions do not. You can use private functions as helper functions, such as described in the next section.


 Invoking Methods on Objects Helper Functions