23.06.2015 Views

MATLAB Programming

MATLAB Programming

MATLAB Programming

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

9 Classes and Objects<br />

Private functions are called if there is no subfunction of the same name<br />

within the current scope. As with subfunctions, even if the function is<br />

called with an argument of type matching that of an overloaded method,<br />

<strong>MATLAB</strong> uses the private function and ignores the overloaded method.<br />

3 Class constructor functions<br />

Constructor functions (functions having names that are the same as the @<br />

directory, for example @polynom/polynom.m) take precedence over other<br />

<strong>MATLAB</strong> functions. Therefore, if you create an M-file called polynom.m and<br />

put it on your path before the constructor @polynom/polynom.m version,<br />

<strong>MATLAB</strong> will always call the constructor version.<br />

4 Overloaded methods<br />

<strong>MATLAB</strong> calls an overloaded method if it is not masked by a subfunction<br />

or private function.<br />

5 Current directory<br />

A function in the current working directory is selected before one elsewhere<br />

on the path.<br />

6 Elsewhere on path<br />

Finally, a function anywhere else on the path is selected.<br />

Selecting Methods from Multiple Directories<br />

There may be a number of directories on the path that contain methods<br />

with the same name. <strong>MATLAB</strong> stops searching when it finds the first<br />

implementation of the method on the path, regardless of the implementation<br />

type (MEX-file, P-code, M-file).<br />

Selecting Methods from Multiple Implementation Types<br />

There are five file precedence types. <strong>MATLAB</strong> uses file precedence to select<br />

between identically named functions in the same directory. The order of<br />

precedence for file types is<br />

1 Built-in file<br />

9-74

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!