23.06.2015 Views

MATLAB Programming

MATLAB Programming

MATLAB Programming

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Overloaded Functions<br />

Overloaded Functions<br />

Overloaded functions are useful when you need to create a function that<br />

responds to different types of inputs accordingly. For instance, you might want<br />

one of your functions to accept both double-precision and integer input, but to<br />

handle each type somewhat differently. You can make this difference invisible<br />

to the user by creating two separate functions having the same name, and<br />

designating one to handle double typesandonetohandleintegers.<br />

See “Classes and Objects: An Overview” on page 9-2 for more information on<br />

overloading functions in <strong>MATLAB</strong>.<br />

Class Directories<br />

<strong>MATLAB</strong> overloaded functions reside in subdirectories having a name<br />

starting with the symbol @ and followed by the name of a recognized <strong>MATLAB</strong><br />

data type. For example, functions in the \@double directory execute when<br />

invoked with arguments of <strong>MATLAB</strong> type double. Thoseinan \@int32<br />

directory execute when invoked withargumentsof<strong>MATLAB</strong>typeint32.<br />

5-37

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

Saved successfully!

Ooh no, something went wrong!