M-File Programming

    MATLAB Programming: A Quick Start
        Kinds of M-Files
        What's in an M-File?
        Providing Help for Your Programs
        Creating M-Files: Accessing Text Editors

    Scripts
        Simple Script Example

    Functions
        Simple Function Example
        Basic Parts of a Function M-File
        Function Names
        How Functions Work
        Checking the Number of Function Arguments
        Passing Variable Numbers of Arguments

    Local and Global Variables
        Persistent Variables
        Special Values

    Data Types
    Keywords
    Operators
        Arithmetic Operators
        Relational Operators
        Logical Operators
        Operator Precedence

    Flow Control
        if, else, and elseif
        switch
        while
        for
        continue
        break
        try ... catch
        return

    Subfunctions
    Private Functions
    Subscripting and Indexing
        Subscripting
        Advanced Indexing

    String Evaluation
        eval
        feval

    Command/Function Duality
    Empty Matrices
        Operating on an Empty Matrix
        Using Empty Matrices with If or While

    Errors and Warnings
        Error Handling with eval and lasterr
        Displaying Error and Warning Messages

    Dates and Times
        Date Formats
        Current Date and Time

    Obtaining User Input
        Prompting for Keyboard Input
        Pausing During Execution

    Shell Escape Functions
    Optimizing MATLAB Code
        Vectorizing Loops
        Preallocating Arrays
        Making Efficient Use of Memory

Character Arrays (Strings)

    Character Arrays
        Creating Character Arrays
        Creating Two-Dimensional Character Arrays
        Converting Characters to Numeric Values

    Cell Arrays of Strings
        Converting to a Cell Array of Strings

    String Comparisons
        Comparing Strings For Equality
        Comparing for Equality Using Operators
        Categorizing Characters Within a String

    Searching and Replacing
    String/Numeric Conversion
        Array/String Conversion

Multidimensional Arrays

    Multidimensional Arrays
        Creating Multidimensional Arrays
        Accessing Multidimensional Array Properties
        Indexing
        Reshaping
        Permuting Array Dimensions

    Computing with Multidimensional Arrays
        Operating on Vectors
        Operating Element-by-Element
        Operating on Planes and Matrices

    Organizing Data in Multidimensional Arrays
    Multidimensional Cell Arrays
    Multidimensional Structure Arrays
        Applying Functions to Multidimensional Structure Arrays

Structures and Cell Arrays

    Structures
        Building Structure Arrays
        Accessing Data in Structure Arrays
        Finding the size of Structure Arrays
        Adding Fields to Structures
        Deleting Fields from Structures
        Applying Functions and Operators
        Writing Functions to Operate on Structures
        Organizing Data in Structure Arrays
        Nesting Structures

    Cell Arrays
        Creating Cell Arrays
        Obtaining Data from Cell Arrays
        Deleting Cells
        Reshaping Cell Arrays
        Replacing Lists of Variables with Cell Arrays
        Applying Functions and Operators
        Organizing Data in Cell Arrays
        Nesting Cell Arrays
        Converting Between Cell and Numeric Arrays
        Cell Arrays of Structures

Function Handles

    Benefits of Using Function Handles
        A Simple Function Handle

    Constructing a Function Handle
        Maximum Length of a Function Name

    Evaluating a Function Through Its Handle
        Function Evaluation and Overloading
        Examples of Function Handle Evaluation

    Displaying Function Handle Information
        Fields Returned by the Functions Command
        Types of Function Handles

    Function Handle Operations
        Converting Function Handles to Function Names
        Converting Function Names to Function Handles
        Testing for Data Type
        Testing for Equality

    Saving and Loading Function Handles
    Handling Error Conditions
        Handles to Nonexistent Functions
        Including Path In the Function Handle Constructor
        Evaluating a Nonscalar Function Handle

    Historical Note - Evaluating Function Names

MATLAB Classes and Objects

    Classes and Objects: An Overview
        Features of Object-Oriented Programming
        MATLAB Data Class Hierarchy
        Creating Objects
        Invoking Methods on Objects
        Private Methods
        Helper Functions
        Debugging Class Methods
        Setting Up Class Directories
        Data Structure
        Tips for C++ and Java Programmers

    Designing User Classes in MATLAB
        The MATLAB Canonical Class
        The Class Constructor Method
        Examples of Constructor Methods
        Identifying Objects Outside the Class Directory
        The display Method
        Accessing Object Data
        The set and get Methods
        Indexed Reference Using subsref and subsasgn
        Handling Subscripted Reference
        Handling Subscripted Assignment
        Object Indexing Within Methods
        Defining end Indexing for an Object
        Indexing an Object with Another Object
        Converter Methods

    Overloading Operators and Functions
        Overloading Operators
        Overloading Functions

    Example - A Polynomial Class
        Polynom Data Structure
        Polynom Methods
        The Polynom Constructor Method
        Converter Methods for the Polynom Class
        The Polynom display Method
        The Polynom subsref Method
        Overloading Arithmetic Operators for polynom
        Overloading Functions for the Polynom Class
        Listing Class Methods

    Building on Other Classes
        Simple Inheritance
        Multiple Inheritance
        Aggregation

    Example - Assets and Asset Subclasses
        Inheritance Model for the Asset Class
        Asset Class Design
        Other Asset Methods
        The Asset Constructor Method
        The Asset get Method
        The Asset set Method
        The Asset subsref Method
        The Asset subsasgn Method
        The Asset display Method
        The Asset fieldcount Method
        Designing the Stock Class
        The Stock Constructor Method
        The Stock get Method
        The Stock set Method
        The Stock subsref Method
        The Stock subsasgn Method
        The Stock display Method

    Example - The Portfolio Container
        Designing the Portfolio Class
        The Portfolio Constructor Method
        The Portfolio display Method
        The Portfolio pie3 Method
        Creating a Portfolio

    Saving and Loading Objects
        Modifying Objects During Save or Load

    Example - Defining saveobj and loadobj for Portfolio
        Summary of Code Changes
        The saveobj Method
        The loadobj Method
        Changing the Portfolio Constructor
        The Portfolio subsref Method

    Object Precedence
        Specifying Precedence of User-Defined Classes

    How MATLAB Determines Which Method to Call
        Selecting a Method
        Querying Which Method MATLAB Will Call