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.

Features of Object-Oriented <strong>Programming</strong> ............. 9-3<br />

<strong>MATLAB</strong> Data Class Hierarchy ...................... 9-3<br />

Creating Objects .................................. 9-4<br />

Invoking Methods on Objects ........................ 9-4<br />

Private Methods .................................. 9-5<br />

Helper Functions .................................. 9-6<br />

Debugging Class Methods .......................... 9-6<br />

Setting Up Class Directories ........................ 9-6<br />

Data Structure ................................... 9-7<br />

Tips for C++ and Java Programmers .................. 9-8<br />

Designing User Classes in <strong>MATLAB</strong> ................. 9-9<br />

The <strong>MATLAB</strong> Canonical Class ....................... 9-9<br />

The Class Constructor Method ....................... 9-10<br />

Examples of Constructor Methods .................... 9-12<br />

Identifying Objects Outside the Class Directory ......... 9-12<br />

The display Method ................................ 9-13<br />

Accessing Object Data .............................. 9-13<br />

The set and get Methods ............................ 9-14<br />

Indexed Reference Using subsref and subsasgn ......... 9-15<br />

Handling Subscripted Reference ..................... 9-16<br />

Handling Subscripted Assignment .................... 9-19<br />

Object Indexing Within Methods ..................... 9-20<br />

Defining end Indexing for an Object .................. 9-20<br />

Indexing an Object with Another Object ............... 9-21<br />

Converter Methods ................................ 9-22<br />

Overloading Operators and Functions ............... 9-23<br />

Overloading Operators ............................. 9-23<br />

Overloading Functions ............................. 9-25<br />

Example — A Polynomial Class ..................... 9-26<br />

Polynom Data Structure ............................ 9-26<br />

Polynom Methods ................................. 9-26<br />

The Polynom Constructor Method .................... 9-27<br />

Converter Methods for the Polynom Class ............. 9-28<br />

The Polynom display Method ........................ 9-30<br />

The Polynom subsref Method ........................ 9-31<br />

Overloading Arithmetic Operators for polynom ......... 9-32<br />

Overloading Functions for the Polynom Class .......... 9-34<br />

Listing Class Methods ............................. 9-36<br />

xvi<br />

Contents

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

Saved successfully!

Ooh no, something went wrong!