Skip to Main Content Skip to Search
Product Documentation

Examples


Use this list to find examples in the documentation.

MATLAB Operators

Arithmetic Operators and Arrays
Relational Operators and Arrays
Element-Wise Operators and Functions
Logical Expressions Using the find Function
Bit-Wise Functions
Overriding Default Precedence

Regular Expressions

Character Type Operators
Grouping Operators
Positional Operators
Lookaround Operators
Using Lookaround as a Logical Operator
Quantifiers
Using Tokens — Example 1
Using Tokens — Example 2
Named Capture
Labeling Your Output
Example of a Dynamic Expression
Dynamic Expressions That Modify the Match Expression — (??expr)
Dynamic Commands That Modify the Match Expression — (??@cmd)
Dynamic Commands That Serve a Functional Purpose — (?@cmd)
Dynamic Commands That Modify the Replacement Expression — ${cmd}

Comma-Separated Lists

Generating a List from a Cell Array
Generating a List from a Structure
Assigning Output from a Comma-Separated List
Assigning to a Comma-Separated List
Constructing Arrays
Displaying Arrays
Concatenation
Function Call Arguments
Function Return Values
Fast Fourier Transform Example

Numeric Classes

Creating Integer Data
Largest and Smallest Values for Integer Classes
Creating Floating-Point Data
Arithmetic Operations on Floating-Point Numbers
Largest and Smallest Values for Floating-Point Classes
Accuracy of Floating-Point Data
Example 1 — Round-Off or What You Get Is Not What You Expect
Example 2 — Catastrophic Cancellation
Example 3 — Floating-Point Operations and Linear Algebra
Creating Complex Numbers
Infinity
NaN
Display Format Examples
Setting Numeric Format in a Program

Logical Classes

Overview of the Logical Class
Examples of Identifying Logical Arrays
Examples of Functions that Return a Logical Result
Using Logical Arrays in Conditional Statements

Logical Data Types

Functions that Return a Logical Result

Characters and Strings

Creating a Character String
Combining Strings Vertically
Combining Strings Horizontally
Working with Space Characters
Converting to a Cell Array of Strings
Formatting Strings
Sequential and Numbered Argument Specification
The Formatting Operator
Specifying Field Width and Precision Outside the format String
Using Identifiers In the Width and Precision Fields
Comparing Strings for Equality
Comparing for Equality Using Operators
Categorizing Characters Within a String
Searching and Replacing
Converting to a Character Equivalent
Converting to a String of Numbers
Converting from a Character Equivalent
Converting from a Numeric String

Structures

Access Data in a Structure Array
Ways to Organize Data in Structure Arrays

Function Handles

Arrays of Function Handles
Calling a Function By Means of Its Handle
Example 1 — Run quad on Varying Functions
Example 2 — Run quad on Anonymous Functions
Example 3 — Compare quad Results on Different Functions
Example 1 — Constructing a Function Handle that Preserves Its Variables
Example 2 — Varying Data Values Stored in a Function Handle
Example 3 — You Cannot Vary Data in a Handle to an Anonymous Function
Examining a Function Handle
Converting a String to a Function Handle
Converting a Function Handle to a String
Comparing Handles Constructed from a Named Function
Comparing Handles to Anonymous Functions
Comparing Handles to Nested Functions
Comparing Handles Saved to a MAT-File

Map Containers

Constructing an Empty Map Object
Constructing An Initialized Map Object
Examining the Contents of the Map
Reading From the Map
Adding Key/Value Pairs
Building a Map with Concatenation
Removing Keys and Values from the Map
Modifying Values
Modifying Keys
Mapping to a Structure Array
Mapping to a Cell Array

Program Files

Basic Parts of a Program File
Creating a Program File
Scripts
Functions
Detailed Display of Program File Dependencies
Subfunctions
Find Number of Function Arguments
Support Variable Number of Inputs
Vectorizing Loops

Anonymous Functions

Constructing an Anonymous Function
A Two-Input Example
Evaluating With No Input Arguments
Changing Variables Used in an Anonymous Function
Example 1 — Passing a Function to quad
Example 2 — Multiple Anonymous Functions

Nested Functions

Writing Nested Functions
Example — More Than One Nested Function
Example — Multiply Nested Functions
Calling Nested Functions
Variable Scope in Nested Functions
The Scope of Output Variables
Using Function Handles with Nested Functions
Defining Variables When Calling Via Function Handle
Example Using Externally Scoped Variables
Separate Instances of Externally Scoped Variables
Example 1 — Creating a Function Handle for a Nested Function
Example 2 — Function-Generating Functions

Error Handling

Formatted Message Strings
Message Identifiers
Output from Control Statements
Output Structure Array
Example 1 — Performing an Explicit Query
Example 2 — Performing an Implicit Query
Example 1 — Enabling Verbose Warnings
Example 2 — Displaying a Stack Trace on a Specific Warning

Events and Callbacks

Writing a Callback Function

Improving Performance

Stopwatch Timer Functions
Simple Example of Vectorizing
Advanced Example of Vectorizing

Help, Demos, and Related Resources

Example of Help for a Externally Supplied Class
Add Documentation to the Help Browser
Add Demos to the Help Browser

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS