C911X_C000.fm Page i Wednesday, April 11, 2007 10:52 AM
A Guide to MATLAB®
Object-Oriented Programming
C911X_C000.fm Page ii Wednesday, April 11, 2007 10:52 AM
C911X_C000.fm Page iii Wednesday, April 11, 2007 10:52 AM
A Guide to MATLAB®
Object-Oriented Programming
Andy H. Register
Georgia Tech Research Institute
Atlanta, Georgia, U.S.A.
C911X_C000.fm Page iv Wednesday, April 11, 2007 10:52 AM
MATLAB® is a trademark of The Mathworks, Inc. and is used with permission. The MathWorks does not warrant the
accuracy of the text or exercises in this book. This book’s use or discussion of MATLAB software or related products
does not constitute endorsement or sponsorship by The MathWorks of a particular pedagogical approach or particular
use of the MATLAB software.
Chapman & Hall/CRC
Taylor & Francis Group
6000 Broken Sound Parkway NW, Suite 300
Boca Raton, FL 33487-2742
© 2007 by SciTech Publishing Inc.
Chapman & Hall/CRC is an imprint of Taylor & Francis Group, an Informa business
No claim to original U.S. Government works
Printed in the United States of America on acid-free paper
10 9 8 7 6 5 4 3 2 1
International Standard Book Number-13: 978-1-58488-911-3 (Softcover)
This book contains information obtained from authentic and highly regarded sources. Reprinted material is quoted
with permission, and sources are indicated. A wide variety of references are listed. Reasonable efforts have been made to
publish reliable data and information, but the author and the publisher cannot assume responsibility for the validity of
all materials or for the consequences of their use.
No part of this book may be reprinted, reproduced, transmitted, or utilized in any form by any electronic, mechanical, or
other means, now known or hereafter invented, including photocopying, microfilming, and recording, or in any informa-
tion storage or retrieval system, without written permission from the publishers.
For permission to photocopy or use material electronically from this work, please access www.copyright.com (http://
www.copyright.com/) or contact the Copyright Clearance Center, Inc. (CCC) 222 Rosewood Drive, Danvers, MA 01923,
978-750-8400. CCC is a not-for-profit organization that provides licenses and registration for a variety of users. For orga-
nizations that have been granted a photocopy license by the CCC, a separate system of payment has been arranged.
Trademark Notice: Product or corporate names may be trademarks or registered trademarks, and are used only for
identification and explanation without intent to infringe.
Library of Congress Cataloging-in-Publication Data
Register, Andy H.
p. cm.
processing. I. Title.
QA76.64.R454 2007
005.1’17--dc22
A guide to MATLAB object-oriented programming / Andy H. Register.
Includes index.
ISBN-13: 978-1-58488-911-3 (alk. paper)
ISBN-10: 1-58488-911-X (alk. paper)
1. MATLAB. 2. Object-oriented programming (Computer science) 3. Numerical analysis--Data
2006100724
Visit the Taylor & Francis Web site at
http://www.taylorandfrancis.com
and the CRC Press Web site at
http://www.crcpress.com
C911X_C000.fm Page v Wednesday, April 11, 2007 10:52 AM
Dedication
For Mickey
C911X_C000.fm Page vi Wednesday, April 11, 2007 10:52 AM
C911X_C000.fm Page vii Wednesday, April 11, 2007 10:52 AM
Table of Contents
Figures..............................................................................................................................................xv
Code Listings ................................................................................................................................ xvii
Tables.............................................................................................................................................. xxi
About the Author ......................................................................................................................... xxiii
Preface ............................................................................................................................................xxv
Chapter 1
Introduction...................................................................................................................1
1.1 Examples...................................................................................................................................2
1.2 Object-Oriented Software Development ..................................................................................2
1.2.1 At the Top of Your Game.............................................................................................3
1.2.2 Personal Development..................................................................................................3
1.2.3 Wicked Problems..........................................................................................................5
1.2.4 Extreme Programming..................................................................................................6
1.2.5 MATLAB, Object-Oriented Programming, and You ...................................................8
1.3 Attributes, Behavior, Objects, and Classes ..............................................................................9
1.3.1 From MATLAB Heavyweight to Object-Oriented Thinker ........................................9
1.3.2 Object-Oriented Design..............................................................................................10
1.3.3 Why Use Objects?......................................................................................................11
1.3.4 A Quality Focus .........................................................................................................12
Reliability...................................................................................................12
Reusability .................................................................................................13
Extendibility...............................................................................................14
Summary.................................................................................................................................15
1.3.4.1
1.3.4.2
1.3.4.3
1.4
PART 1
Group of Eight ........................................................ 17
Chapter 2
Meeting MATLAB’s Requirements ...........................................................................19
2.1 Variables, Types, Classes, and Objects ..................................................................................19
2.2 What Is a MATLAB Class? ...................................................................................................21
2.2.1 Example: Class Requirements....................................................................................21
Class Directory ..........................................................................................22
Constructor.................................................................................................22
The Test Drive ...........................................................................................24
Summary.................................................................................................................................26
Independent Investigations .....................................................................................................27
2.2.1.1
2.2.1.2
2.2.1.3
2.3
2.4
vii