Use this example index to jump to code examples in the documentation.

M-File Programming

Simple Function Example
Simple Script Example
Passing Variable Numbers of Arguments
Checking the Number of Function Arguments
Accessing Single Elements of a Matrix
Accessing Multiple Elements of a Matrix
Expanding the Size of a Matrix
Deleting Rows and Columns
Concatenating Matrices
Conversions Between Date Formats
Vectorizing Loops

Character Arrays (Strings)

Comparing Strings For Equality
Converting to a Cell Array of Strings
Converting Characters to Numeric Values
Creating Two-Dimensional Character Arrays
Searching and Replacing
Categorizing Characters Within a String

Multidimensional Arrays

Generating Arrays Using Indexing
Generating Arrays Using MATLAB Functions
Building Multidimensional Arrays with the cat Function
Operating on Planes and Matrices
Multidimensional Cell Arrays
Multidimensional Structure Arrays

Structures and Cell Arrays

Building Structure Arrays Using Assignment Statements
Writing Functions to Operate on Structures
Accessing Data in Structure Arrays
Building Nested Structures with the struct Function
Creating Cell Arrays
Replacing Lists of Variables with Cell Arrays
Reshaping Cell Arrays
Accessing Cell Contents Using Content Indexing
Nesting Cell Arrays
Cell Arrays of Structures

Function Handles

Constructing a Function Handle
Simple Function Handles
Overloaded Function Handles
Constructor Function Handles
Subfunction Handles
Private Function Handles
Function File
Function Methods
Displaying Function Handle Information
Example 1 - A Simple Function Handle
Example 2 - Function Handles and Subfunctions
Converting Function Names to Function Handles
Converting Function Handles to Function Names

MATLAB Classes and Objects

Example -- A Polynomial Class
How to Write subsref
Designing the Stock Class
Assets and Asset Subclasses
Example -- The Portfolio Container
Example -- Defining saveobj and loadobj for Portfolio

Improving M-File Performance - The Profiler

An Example Using profile