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.

Overloading Operators and Functions<br />

Operation M-File Description<br />

[a b] horzcat(a,b,...) Horizontal concatenation<br />

[a; b] vertcat(a,b,...) Vertical concatenation<br />

a(s1,s2,...sn) subsref(a,s) Subscripted reference<br />

a(s1,...,sn) = b subsasgn(a,s,b) Subscripted assignment<br />

b(a) subsindex(a) Subscript index<br />

Overloading Functions<br />

You can overload any function by creating a function of the same name in the<br />

classdirectory. Whenafunctionisinvokedonanobject,<strong>MATLAB</strong>always<br />

looks in the class directory before any other location on the search path. To<br />

overload the plot function for a class of objects, for example, simply place<br />

your version of plot.m in the appropriate class directory.<br />

Examples of Overloaded Functions<br />

See the following sections for examples of overloaded functions:<br />

• “Overloading Functions for the Polynom Class” on page 9-34<br />

• “The Portfolio pie3 Method” on page 9-61<br />

9-25

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

Saved successfully!

Ooh no, something went wrong!