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.

Building on Other Classes .......................... 9-38<br />

Simple Inheritance ................................ 9-38<br />

Multiple Inheritance ............................... 9-40<br />

Aggregation ...................................... 9-40<br />

Example — Assets and Asset Subclasses ............. 9-41<br />

Inheritance Model for the Asset Class ................. 9-42<br />

Asset Class Design ................................ 9-42<br />

Other Asset Methods .............................. 9-43<br />

The Asset Constructor Method ....................... 9-43<br />

The Asset get Method .............................. 9-44<br />

The Asset set Method .............................. 9-45<br />

The Asset subsref Method .......................... 9-46<br />

The Asset subsasgn Method ......................... 9-47<br />

The Asset display Method ........................... 9-48<br />

The Asset fieldcount Method ........................ 9-49<br />

Designing the Stock Class .......................... 9-49<br />

The Stock Constructor Method ....................... 9-50<br />

The Stock get Method .............................. 9-52<br />

The Stock set Method .............................. 9-53<br />

The Stock subsref Method .......................... 9-54<br />

The Stock subsasgn Method ......................... 9-55<br />

The Stock display Method ........................... 9-57<br />

Example — The Portfolio Container ................. 9-58<br />

Designing the Portfolio Class ........................ 9-58<br />

The Portfolio Constructor Method .................... 9-59<br />

The Portfolio display Method ........................ 9-60<br />

The Portfolio pie3 Method ........................... 9-61<br />

Creating a Portfolio ................................ 9-62<br />

Saving and Loading Objects ........................ 9-64<br />

Modifying Objects During Save or Load ............... 9-64<br />

Example — Defining saveobj and loadobj for<br />

Portfolio ........................................ 9-65<br />

Summary of Code Changes .......................... 9-65<br />

The saveobj Method ............................... 9-66<br />

The loadobj Method ................................ 9-66<br />

Changing the Portfolio Constructor ................... 9-67<br />

The Portfolio subsref Method ........................ 9-68<br />

xvii

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

Saved successfully!

Ooh no, something went wrong!