| Contents | Index |
• Desktop Tools and Development Environment
• Desktop
• Running Functions - Command Window and History
• Open Command Window, Create Variables, and Run Code
• Create MATLAB Shortcuts to Rerun MATLAB Commands
Create Files from, Run, and Copy Command History Commands
• Adjust Command Window Appearance
• Adjust Command History Window Appearance
• Command Window Code and Output Display
• Avoid Mistakes When Entering Code
Highlight Syntax to Help Ensure Correct Entries in the Command Window
Avoid Mismatched Parentheses, Brackets, Braces, and Paired Keywords
• Find Text in the Command Window
Find Text Currently Displayed in the Command Window
Increase the Amount of Information Available for Searching in the Command Window
• Help and Product Information
• Workspace Browser and Variable Editor
Viewing and Editing Values in the Workspace
Improving Workspace Browser Performance
Loading a Saved Workspace and Importing Data
Changing and Copying Variable Names in the Workspace
Creating Plots from the Workspace Browser
Opening Variables and Objects for Viewing and Editing
Working with Different Data Types in the Variable Editor
Navigating the Variable Editor Using Shortcut Keys
Changing Size, Content, and Format of Variables in the Variable Editor
Selecting and Modifying Values in the Variable Editor
Exchanging Variable Editor Data with Other Tools and Applications
Creating Graphs and Variables, and Data Brushing in the Variable Editor
Using the Current Folder Browser
Simple Search for File and Folder Names in the Current Folder Browser
Advanced Search for Files - Find Files Tool
Locating a File or Folder in the Operating System Browser
Finding Files and Folders Using Functions
Copying, Renaming, and Deleting Files and Folders
Comparing Folders and Zip Files
Comparing Files with Autosave Version or Version on Disk
Using Comparison Tool Features
Function Alternative for Comparing Files and Folders
Determining if MATLAB Can Access a File
Ensuring MATLAB Uses the File You Want
Viewing Files and Folders on the Search Path
Using the Search Path with Different MATLAB Installations
Recovering from Problems with the Search Path
Handling Errors and Unexpected Behavior When Updating Folders
• File Exchange - Finding and Getting Files Created by Other Users
What You Need to Use File Exchange
Ways to Access the File Exchange Repository
Example - Finding and Downloading a File in File Exchange
Using Search to Find Files in File Exchange
Finding Files by Product, Author, and Other Attributes in File Exchange
Using Tags to Find Files in File Exchange
Getting Better Results Using Search and Tags
Sorting the List of Files in File Exchange
Viewing the Contents of a File
Downloading from the List of Files
Downloading from the File Details Page to a Location You Choose
The Default Folder for Downloaded Files
Which Location Should You Choose When Downloading Files?
Downloading a Submission that Consists of Multiple Files
Viewing and Locating Files You Downloaded
Providing Comments About a File
Submitting Your Files to the Repository
How Does the File Exchange Desktop Tool Relate to File Exchange on the Web Site?
Why Do I See Only 50 Files and How Can I See More?
What Are Tags and How Do I Use Them?
What Are the Tags Above the List of Files?
Is Search Looking Inside Files?
How Can I Start Over When Looking for Files?
• Editing and Debugging MATLAB Code
Line and Column Number Indicators
Right-Side Text Limit Indicator
Cursor Location Indicator - Class, Function, or Subfunction
Display Two Parts of a File Simultaneously
Change the Case of Selected Text
Code Folding - Expand and Collapse Code Constructs
Colors in the MATLAB Editor - What Do They Mean?
Code Contains %#ok - What Does That Mean?
Navigate Backward and Forward in Files
Open a File or Variable from Within a File
Find and Replace Functions or Variables in the Current File
Automatically Rename All Functions or Variables in a File
Find Text in Multiple File Names or Files
Function Alternative for Finding Text
Perform an Incremental Search in the Editor
Run Files with Input Arguments in the Editor
Create and Use a Run Configuration
Use a Previously Created Run Configuration
Create and Execute Multiple Run Configurations for a File
About the run_configurations.m File
Reassociate and Rename Configurations
Scenarios for Evaluating Sections of Code
Process for Evaluating Sections of Files
Navigate Among Code Cells in a File
Complete Names in the Editor Using the Tab Key
Check Code for Errors and Warnings
Avoid Variable and Function Scoping Problems
Correct Problems and End Debugging
Breakpoints in Anonymous Functions
Breakpoints in Methods That Overload Functions
Editor/Debugger Display Preferences
Editor/Debugger Tab Preferences
Editor/Debugger Language Preferences
Editor/Debugger Code Folding Preferences
Editor/Debugger Autosave Preferences
Filtering Messages in the Code Analyzer Preferences Dialog Box
• Tuning and Managing MATLAB Code Files
Refining and Improving Files Using Reports
Identifying Files with Reminder Annotations
Generating a Summary View of the Help Components in Functions and Scripts
Displaying and Updating a Report on the Contents of a Folder
What Is Meant by Publishing MATLAB Code?
Process for Publishing MATLAB Code
Example of Published MATLAB Code
Adding the Markup for the Example
Overview of Marking Up MATLAB Comments for Publishing
Creating Document Titles and Introductory Text for Publishing an Existing File
Specifying Preformatted Text in MATLAB Files for Publishing
Specifying Bulleted or Numbered Lists in MATLAB Files for Publishing
Specifying Graphics in MATLAB Files for Publishing
Using HTML Markup Tags in MATLAB Files for Publishing
Using LaTeX Markup for Publishing
Including Inline LaTeX Math Equations in MATLAB Files for Publishing
Including LaTeX Display Math in MATLAB Files for Publishing
Forcing a Snapshot of Output in MATLAB Files for Publishing
Including Bold, Italic, and Monospaced Text in MATLAB Files for Publishing
Including Trademarks in MATLAB Files for Publishing
Including Hyperlinks in MATLAB Files for Publishing
Cleaning Up Text Markup Before Publishing MATLAB Files
Summary of Markup for Publishing MATLAB Files
Specifying the Display of Code Output
Creating a Publish Configuration for a MATLAB File
Running an Existing Publish Configuration
Creating Multiple Publish Configurations for a File
About the publish_configurations.m File
Finding Publish Configurations
• Creating a MATLAB Notebook to Publish to Microsoft Word
Creating or Opening a MATLAB Notebook
Entering Commands in a MATLAB Notebook
Protecting the Integrity of Your Workspace in MATLAB Notebooks
Ensuring Data Consistency in MATLAB Notebooks
Debugging and MATLAB Notebooks
Defining Input Cells for a MATLAB Notebook
Defining Cell Groups for a MATLAB Notebook
Defining Autoinit Input Cells for a MATLAB Notebook
Defining Calc Zones for a MATLAB Notebook
Converting an Input Cell to Text in a MATLAB Notebook
Evaluating a Range of Input Cells
Evaluating an Entire MATLAB Notebook
Using a Loop to Evaluate Input Cells Repeatedly
Converting Output Cells to Text
Modifying Styles in the MATLAB Notebook Template
Choosing Loose or Compact Format
Create Projects in Source Control System
Specify Source Control System with MATLAB Software
Register Source Control Project with MATLAB Software
Check Files Into Source Control
Check Files Out of Source Control
Removing Files from the Source Control System
Comparing the Working Copy of a File to the Latest Version in Source Control
Viewing Source Control Properties of a File
Starting the Source Control System
Restriction Against @ Character
Add to Source Control Is the Only Action Available
More Solutions for Source Control Problems
Setting a View and Checking Out a Folder with ClearCase Software on UNIX Platforms
Checking In One File Using the Editor, or the Simulink or Stateflow Products
Checking Out a Single File Using the Editor, or the Simulink or Stateflow Products
Undoing the Checkout for One or More Files Using the Current Folder Browser
Undoing the Checkout for a Single File Using the Editor, or the Simulink or Stateflow Products
Windows Platform-Specific Behavior
Tools that Import Multiple File Formats
Importing Specific File Formats
Importing Data in Other Formats
Processing a Sequence of Files
Tips for Using the Import Wizard
View the Contents of a MAT-File
Ways to Load Data from a MAT-File
Load Part of a Variable from a MAT-File
Troubleshooting: Loading Variables within a Function
Import Numeric Data from a Text File
Import Numeric Data and Header Text from a Text File
Import Mixed Text and Numeric Data from a Text File
Import Data from a Nonrectangular Text File
Import Text Data Files with Low-Level I/O
Example - Finding Text in an XML File
Select Spreadsheet Data Interactively
Import a Worksheet or Range with xlsread
Import All Worksheets in a File with importdata
System Requirements for Importing Spreadsheets
When to Convert Dates from Excel Files
Importing Network Common Data Form (NetCDF) Files
Importing Flexible Image Transport System (FITS) Files
Importing Hierarchical Data Format (HDF5) Files
Importing Hierarchical Data Format (HDF4) Files
Reading Image Data and Metadata from TIFF Files
Reading Files Created on Other Systems
Opening Files with Different Character Encodings
Save Part of a Variable in a MAT-File
Save Structure Fields as Separate Variables
Writing to Text Data Files with Low-Level I/O
File Formats that xlswrite Supports
Formatting Cells in Excel Files
Exporting to Network Common Data Form (NetCDF) Files
Exporting to Hierarchical Data Format (HDF5) Files
Exporting to Hierarchical Data Format (HDF4) Files
Overwriting or Appending to an Existing File
Creating a File for Use on a Different System
Opening Files with Different Character Encodings
Writing and Reading Complex Numbers
Constructing the Object with Default Property Values
Setting the Start of the Mapped Region
Identifying the Contents of the Mapped Region
Example 1 - Reading a Single Data Type
Example 2 - Formatting File Data as a Matrix
Example 3 - Reading Multiple Data Types
Example 4 - Modifying Map Parameters
Writing Matrices to a Mapped File
Selecting Appropriate Data Types
Matrix Concatenation Functions
Functions That Control Indexing Style
Using Logicals in Array Indexing
Single-Colon Indexing with Different Array Types
Data Structures Used in the Matrix
Diminishing the Size of a Matrix
Shifting the Location of Matrix Elements
Sorting the Data in Each Column
Constructing a Matrix from a Diagonal Vector
Returning a Triangular Portion of a Matrix
Concatenating Matrices Diagonally
Creating Multidimensional Arrays
Accessing Multidimensional Array Properties
Indexing Multidimensional Arrays
Reshaping Multidimensional Arrays
Computing with Multidimensional Arrays
Organizing Data in Multidimensional Arrays
Multidimensional Structure Arrays
Adding and Subtracting Matrices
Using Multithreaded Computation with Linear Algebra Functions
Using Multithreaded Computation with Systems of Linear Equations
Iterative Methods for Solving Systems of Linear Equations
Using Multithreaded Computation for Factorization
Choosing a Random Number Generator
Initializing the Generator with an Integer Seed
Initializing the Generator with a State Vector
If You Are Unable to Upgrade from Former Syntax
Functions That Do Not Support Sparse Matrices
Functions with Sparse Alternatives
Indexing in Sparse Matrix Operations
Eigenvalues and Singular Values
Triangulation Face-Vertex Format
Querying Triangulations Using TriRep
Creating Delaunay Triangulations
Triangulation of Point Sets Containing Duplicate Locations
Searching Non-Delaunay Triangulations
Interpolation with the interp Family of Functions
Interpolation with the griddedInterpolant Class
Interpolating Scattered Data Using griddata and griddatan
Interpolating Scattered Data Using the TriScatteredInterp Class
Addressing Problems in Scattered Data Interpolation
Minimizing Functions of Several Variables
Creating and Using an Output Function
Structure of the Output Function
Importing Data into the Workspace
Exporting Data from the Workspace
Example: Loading and Plotting Data
Representing Missing Data Values
Example: Moving Average Filter
Example: Removing Linear Trends from Data
Example: Using MATLAB Data Statistics
Using Data Tips to Explore Graphs
Example - Visually Exploring Demographic Statistics
Fitting Data with Curve Fitting Toolbox Functions
Example: Using Basic Fitting GUI
Linear Model with Nonpolynomial Terms
Example: Time Series Objects and Methods
Time Series Collection Constructor
Editing Data, Time, Attributes, and Events
How MATLAB Recognizes Command Syntax
How to Use the Different Classes
Display Format for Numeric Values
Functions that Return a Logical Result
Using Logical Arrays in Conditional Statements
Using Logical Arrays in Indexing
Converting from Numeric to String
Converting from String to Numeric
Access Data in a Structure Array
Generate Field Names from Variables
Access Data in Nested Structures
Access Multiple Elements of a Nonscalar Struct Array
Ways to Organize Data in Structure Arrays
Memory Requirements for a Structure Array
Pass Contents of Cell Arrays to Functions
Preallocate Memory for a Cell Array
Multilevel Indexing to Access Parts of Cells
Calling a Function By Means of Its Handle
Preserving Data from the Workspace
Applications of Function Handles
Saving and Loading Function Handles
Advanced Operations on Function Handles
Functions That Operate on Function Handles
Examining the Contents of the Map
Reading and Writing Using a Key Index
Modifying Keys and Values in the Map
Mapping to Different Value Types
Combining Integer and Noninteger Data
Combining Cell Arrays with Non-Cell Arrays
Working with Serial Date Numbers
Calling Regular Expression Functions from MATLAB
Parsing Strings with Regular Expressions
Other Benefits of Using Regular Expressions
Function, Mode Options, Operator, Return Value Summaries
Generating a Comma-Separated List
Assigning Output from a Comma-Separated List
Assigning to a Comma-Separated List
How to Use the Comma-Separated Lists
Fast Fourier Transform Example
Providing Help for Your Program
Cleaning Up When the Function Completes
Determining Which Function Gets Called
Resolving Difficulties In Calling Functions
Passing Arguments in Structures or Cell Arrays
Working with the Example Function
Validating Data Passed to a Function
Calling a Function that Uses the Input Parser
Substituting Default Values for Arguments Not Passed
Interpreting Arguments Passed as Structures
Other Features of the Input Parser
Summary of inputParser Methods and Properties
Outputs from Anonymous Functions
Variables Used in the Expression
Examples of Anonymous Functions
Variable Scope in Nested Functions
Using Function Handles with Nested Functions
Restrictions on Assigning to Variables
Accessing Help for a Subfunction
Accessing Help for a Private Function
Getting Comfortable with Objects
What Are Objects and Why Use Them?
Objects In the MATLAB Language
Other Kinds of Objects Used by MATLAB
Using General-Purpose Data Structures
Classes Describe How to Create Objects
Events are Notices Broadcast to Listening Objects
Class of Objects Returned by Methods
Editing Objects with the Variable Editor
Information About Class Members
Getting Help for MATLAB Objects
Testing for Handle or Value Class
Difference Between clear and delete
Getting an Exception at the Command Line
Getting an Exception in Your Program Code
Properties of the MException Class
Methods of the MException Class
Suggestions on How to Handle an Exception
Output from Control Statements
Setting the Value of Timer Object Properties
Starting a Timer at a Specified Time
Blocking the MATLAB Command Line
Specifying the Value of Callback Function Properties
Executing a Timer Callback Function Multiple Times
Handling Callback Function Queuing Conflicts
Testing the Validity of a Timer Object
Finding Invisible Timer Objects
Using Appropriate Logical Operators
Overloading Built-In Functions
Functions Are Generally Faster Than Scripts
Load and Save Are Faster Than File I/O Functions
Avoid Large Background Processes
Using Appropriate Data Storage
How to Avoid Fragmenting Memory
Using the 3GB Switch on Windows Systems
Freeing Up System Resources on Windows Systems
Help Summary for Your Program Files (Contents.m)
Learning to Add Help from Examples
Summary of Creating and Installing HTML Help Files
Creating Function Reference Pages
Creating Function and Block Category Listings
Making Your HTML Help Files Searchable
Summary of Workflow for Providing HTML Help Files
Entities Missing or Out of Order in info.xml
Invalid Constructs in info.xml File
Outdated info.xml File for a MathWorks Product
Completing Commands Using the Tab Key
Suppressing Output to the Screen
Help on Functions from the Help Browser
Help on Functions from the Command Window
Help for Subfunctions and Private Functions
Help for Methods and Overloaded Functions
Using the Find and Replace Utility
Commenting Out a Block of Code
Creating Functions from Command History
Using Lowercase for Function Names
Getting a Function's Name and Path
What Files Does a Function Use?
Dependent Functions, Built-Ins, Classes
Passing Arguments in a Structure
Passing Arguments in a Cell Array
Selecting the Right Data Structures
Functions with One Calling Function
A Quick Way to Examine Variables
Setting Breakpoints from the Command Line
Finding Line Numbers to Set Breakpoints
Stopping Execution on an Error or Warning
Locating an Error from the Error Message
Making Sure Variable Names Are Valid
Do Not Use Function Names for Variables
Checking for Reserved Keywords
Avoid Using i and j for Variables
Avoid Overwriting Variables in Scripts
Protecting Persistent Variables
Comparing Methods of Concatenation
Store Arrays of Strings in a Cell Array
Converting Between Strings and Cell Arrays
Search and Replace Using Regular Expressions
Assigning to a Series of Variables
Short-Circuit Logical Operators
Changing the Counter Variable within a for Loop
Adding a Folder to the Search Path
Handles to Functions Not on the Path
Making Toolbox File Changes Visible to MATLAB
Making Nontoolbox File Changes Visible to MATLAB
Change Notification on Windows
Multiple Conditions in a case Statement
Catching Errors with try-catch
Forcing an Early Return from a Function
Loading Data into the Workspace
Viewing Variables in a MAT-File
Save and Load on Startup or Quit
Passing Filenames as Arguments
Passing Filenames to ASCII Files
Determining Filenames at Run-Time
Reading Files with Different Formats
Interactive Input into Your Program
Constructing Paths and Filenames
Finding the MATLAB Root Folder
Temporary Directories and Filenames
MATLAB Programmer Without Object-Oriented Programming Experience
MATLAB Programmer with Object-Oriented Programming Experience
Approaches to Writing MATLAB Programs
When Should You Start Creating Object-Oriented Programs
Learning Object-Oriented Programming
Implementing the BankAccount Class
Implementing the AccountManager Class
Performing a Task with an Object
Defining the TensileData Class
Creating an Instance and Assigning Data
Restricting Properties to Specific Values
Simplifying the Interface with a Constructor
Displaying TensileData Objects
A Method to Plot Stress vs. Strain
Important Concepts Demonstrated
Why a Handle Class for Doubly Linked Lists?
Grouping Classes with Package Folders
More Information on Class Folders
How to Initialize Property Values
Assigning Property Values from Within the Constructor
Initializing Properties to Unique Values
Referencing Object Properties Using Variables
More Detailed Information On Methods
Defining Class-Related Functions
Overloading Functions and Operators
Simpler Syntax for true/false Attributes
Warnings Caused by Variable/Property Name Conflicts
Exception to Variable/Property Name Rule
Using Switch/Case Statements with Objects
New Features Introduced with Version 7.6
Common Object-Oriented Techniques
How MATLAB Evaluates Expressions
Access to Functions Defined in Private Folders
Class Precedence and MATLAB Path
Referencing Package Members Within Packages
Referencing Package Members from Outside the Package
Behavior of MATLAB Built-In Classes
Behavior of User-Defined Classes
Finding Handle Object Properties
Specifying Property Attributes
Set and Get Methods for Dependent Properties
Set and Get Method Execution and Property Events
Access Methods and Subscripted Reference and Assignment
Performing Additional Steps with Property Access Methods
Responding to Dynamic-Property Events
Defining Property Access Methods for Dynamic Properties
Dynamic Properties and ConstructOnLoad
Determining Which Method Is Invoked
Invoking Superclass Methods in Subclass Methods
Examples of Class Constructors
Initializing the Object Within a Constructor
Errors During Class Construction
Basic Structure of Constructor Methods
Rules for Naming to Avoid Conflicts
Object Scope and Anonymous Functions
Example - Class Method as a Slider Callback
Initializing Arrays of Value Objects
Initial Value of Object Properties
Initializing Arrays of Handle Objects
Referencing Property Values in Object Arrays
Object Arrays with Dynamic Properties
Converting to the Dominant Class
Implementing Converter Methods
Defining Listener Callback Functions
Example Property Event and Listener Classes
Aborting Set When Value Does Not Change
Access Fully Commented Example Code
Techniques Demonstrated in This Example
Methods Inherited from Handle Class
Using the fcneval and fcnview Classes
Implementing the UpdateGraph Event and Listener
Implementing the PostSet Property Event and Listener
Enabling and Disabling the Listeners
Implementation and Interface Inheritance
Referencing Superclasses from Subclasses
Constructor Arguments and Object Initialization
Call Only Direct Superclass from Constructor
Sequence of Constructor Calls in a Class Hierarchy
Using a Subclass to Create an Alias for an Existing Class
Modifying Superclass Properties
Private Local Property Takes Precedence in Method
Defining Handle-Compatible Classes
Subclassing Handle-Compatible Classes
Methods for Handle Compatible Classes
Handle Compatible Classes and Heterogeneous Arrays
Behavior of Built-In Functions with Subclass Objects
Example - A Class to Manage uint8 Data
Example - Adding Properties to a Built-In Subclass
Example - A Class to Represent Hardware
Interfaces and Abstract Classes
Example - Interface for Classes Implementing Graphs
When to Modify Object Saving and Loading
Processing Objects During Load
Avoiding Property Initialization Order Dependency
When to Use Transient Properties
Calling Constructor When Loading
Defining Methods in Enumeration Classes
Defining Properties in Enumeration Classes
Restrictions Applied to Enumeration Classes
Techniques for Defining Enumerations
Why Derive Enumeration Class from Built-In Classes
Superclass Constructor Returns Underlying Value
Selecting Handle- or Value-Based Enumerations
Value-Based Enumeration Classes
Handle-Based Enumeration Classes
Example - Using Enumerations to Represent a State
Built-In and Value-Based Enumeration Classes
Simple and Handle-Based Enumeration Classes
What Causes Loading as a Struct Instead of an Object
Setting Constant Property Default
Metaclass EnumeratedValues Property
Find Class Members with Attribute Settings
Example - Find Properties with Specific Attributes
Which Methods Control Which Behaviors
Overloading and Overriding Functions and Methods
When to Overload MATLAB Functions
Caution When Overloading MATLAB Functions
Default Indexed Reference and Assignment
subsref and subsasgn Within Class Methods - Built-In Called
Understanding Indexed Reference
Avoid Overriding Access Attributes
Understanding Indexed Assignment
A Class with Modified Indexing
Defining end Indexing for an Object
MATLAB Operators and Associated Functions
Summary of the DocPolynom Class
The DocPolynom Constructor Method
Removing Irrelevant Coefficients
Converting DocPolynom Objects to Other Types
Defining Arithmetic Operators for DocPolynom
Overloading MATLAB Functions for the DocPolynom Class
Designing a Class for Financial Assets
The DocAsset Constructor Method
Designing a Class for Stock Assets
Designing a Class for Bond Assets
Designing a Class for Savings Assets
Summary of the DocSavings Class
Designing the DocPortfolio Class
Summary of the DocPortfolio Class
• Graphics
Plotting Tools Interface Overview
Accessing Object Properties with the Property Inspector
Identifying Workspace Data to Plot
Data Sources for Multiobject Graphs
Using Functions to Edit Graphs
Cutting, Copying, and Pasting Plot Objects
Undo/Redo - Eliminating Mistakes
Saving to a Different Format - Exporting Figures
Generating a MATLAB File to Recreate a Graph
Customizing Data Exploration Tools
Display Style - Datatip or Cursor Window
Selection Style - Select Data Points or Interpolate Points on Graph
Exporting Data Value to Workspace Variable
Rotation Style for Complex Graphs
Undo/Redo - Eliminating Mistakes
Enclosing Regions of a Graph in a Rectangle or an Ellipse
Pinning - Attaching to a Point in the Graph
Example - Vertical Distribute, Horizontal Align
Snap to Grid - Aligning Objects on a Grid
Using the Title Option on the Insert Menu
Using the Property Editor to Add a Title
Using the Label Options on the Insert Menu
Using the Property Editor to Add Axis Labels
Creating Text Annotations with the text or gtext Function
Mathematical Symbols, Greek Letters, and TeX Characters
Using Character and Numeric Variables in Text
Example - Using LaTeX to Format Math Equations
Editing Arrows and Line Annotations
Displaying Multiple Plots per Figure
Colors, Line Styles, and Markers
Specifying the Color and Size of Lines
Adding Plots to an Existing Graph
Line Styles for Black and White Output
Combining Linear and Logarithmic Axes
Example - Specifying Ticks and Tick Labels
Coloring 2-D Bars According to Height
Coloring 3-D Bars According to Height
Stacked Bar Graphs to Show Contributing Amounts
Overlaying Other Plots on Bar Graphs
Comparing Data Sets with Area Graphs
Removing a Piece from a Pie Chart
Histograms in Cartesian Coordinates
Histograms in Polar Coordinates
Using Data Cursors with Histograms
Combining Stem Plots with Line Plots
Three-Dimensional Quiver Plots
Changing the Offset of a Contour
Displaying Contours in Polar Coordinates
Example - Visualizing an FFT as a Movie
Updating Plot Object Axis and Color Data
Functions for Reading, Writing, and Displaying Images
8-Bit and 16-Bit Intensity Images
Mathematical Operations Support for uint8 and uint16
Other 8-Bit and 16-Bit Array Support
Converting an 8-Bit RGB Image to Grayscale
Summary of Image Types and Numeric Classes
Subsetting a Graphics Image (Cropping)
Obtaining Information About Graphics Files
Controlling Aspect Ratio and Display Size
Additional Techniques for Fast Image Updating
Specifying Parameters and Options
Default Settings and How to Change Them
Exporting to the Windows or Macintosh Clipboard
Printing with a Specific Paper Size
Exporting in a Specific Graphics Format
Exporting in EPS Format with a TIFF Preview
Exporting a Figure to the Clipboard
Setting the Figure Size and Position
Setting the Paper Size or Type
Setting the Axes Ticks and Limits
Setting Line and Text Characteristics
Setting the Line and Text Color
Specifying a Colorspace for Printing and Exporting
Excluding User Interface Controls form Printed Output
Frequently Used Graphics Formats
Factors to Consider in Choosing a Format
Properties Affected by Choice of Format
Impact of Rendering Method on the Output
Description of Selected Graphics Formats
How to Specify a Format for Exporting
Factors to Consider in Choosing a Driver
How to Specify the Printer Driver to Use
Information on Specific Graphics Objects
Figures Used for Graphing Data
Root Object - The Figure Parent
Example - Creating Core Graphics Objects
High-Level Versus Low-Level Functions
Identifying Plot Objects Programmatically
Plot Objects and Backward Compatibility
Changing the Size of Data Variables
Example - Enclosing Subplots with an Annotation Rectangle
Order Dependence of Setting Property Values
Properties Common to All Objects
How MATLAB Searches for Default Values
Examples - Setting Default Line Styles
The Current Figure, Axes, and Object
Searching for Objects by Property Values - findobj
Specifying the Target for Graphics Output
Preparing Figures and Axes for Graphics
Targeting Graphics Output with newplot
Quitting the MATLAB Environment
Errors in the Close Request Function
Overriding the Close Request Function
Redefining the CloseRequestFcn
Example - Translating Grouped Objects
Properties for Controlling Legend Content
Example - Excluding a Particular Object From a Legend
Example - One Legend Entry for a Group of Objects
Example - Showing Children of Group Objects in Legend
Example - Grouping Objects to Reduce the Legend Entries
User Interface Object Callbacks
Why Use Function Handle Callbacks
Example - Using Function Handles in GUIs
General Performance Guidelines
Specify Axes with Plotting Function for Better Performance
Performance of Bit-Mapped Images
Performance of Surface Objects
Figure Properties That Affect Docking
Example - Specifying Figure Position
Specifying the Figure Colormap
Creating Axes with Specific Characteristics
Using OuterPosition as the ActivePositionProperty
ActivePositionProperty = OuterPosition
ActivePositionProperty = Position
Multiple Axes for Different Scaling
Basic 3-D Plotting: The plot3 function
Functions for Plotting Data Grids
Visualizing Functions of Two Variables
Surface Plots of Nonuniformly Sampled Data
Indexed Color Surfaces - Direct and Scaled Color Mapping
Example - Mapping Surface Curvature to Color
Move Camera Horizontally/Vertically
Move Camera Forward and Backward
Defining the Camera Path as a Stream Line
Moving In and Out on the Scene
Making the Scene Larger or Smaller
Rotation Without Resizing of Graphics Objects
Rotation About the Viewing Axis
Projection Types and Camera Location
Example - axis Command Options
Additional Commands for Setting Aspect Ratio
Default Aspect Ratio Selection
Effects of Setting Aspect Ratio Properties
Example - Displaying Cross-Sections of Surfaces
Example - Displaying Real Objects
Properties That Affect Lighting
Positioning Lights in Data Space
Example - A Transparent Isosurface
Mapping Alpha Data to the Alphamap
Example - Mapping Data to Color or Transparency
Example - Modifying the Alphamap
Behavior of the patch Function
Handling Mixed Data Specification
Coloring Edges with Shared Vertices
Interpolating in Indexed Color Versus Truecolor
Selecting Visualization Techniques
Steps to Create a Volume Visualization
Volume Visualization Functions
Example - Ways to Display MRI Data
Example - Adding Isocaps to an Isosurface
Using Scalar Techniques with Vector Data
Specifying Starting Points for Stream Plots
Accessing Subregions of Volume Data
1. Determine the Range of the Coordinates
2. Add Slice Planes for Visual Context
3. Add Contour Lines to the Slice Planes
4. Define the Starting Points for the Stream Lines
1. Select a Subset of Data to Plot
2. Calculate Curl Angular Velocity and Wind Speed
4. Define the View and Add Lighting
1. Load Data and Calculate Required Values
3. Add Contour Lines to Slice Planes
1. Specify Starting Points of the Data Range to Plot
2. Create Stream Lines to Indicate Particle Paths
4. Calculate the Stream Particle Vertices
2. Add Isocaps to the Isosurface
• Creating Graphical User Interfaces
• About the Simple GUIDE GUI Example
• Lay Out the Simple GUI in GUIDE
• Program the Simple GUIDE GUI
• Use the Completed Simple GUIDE GUI
Create the Simple Programmatic GUI Code File
• Lay Out the Simple Programmatic GUI
• Code the Simple Programmatic GUI
• Use the Completed Simple Programmatic GUI
A Working GUI with Many Components
Add Components to the GUIDE Layout Area
Define User Interface Controls
Define Panels and Button Groups
• Designing for Cross-Platform Compatibility
• Default Callback Properties in GUIDE
• Customizing Callbacks in GUIDE
• Add Code for Components in Callbacks
• Making Multiple GUIs Work Together
Example - Manipulating a Modal Dialog Box for User Input
Example - Individual GUIDE GUIs Cooperating as Icon Manipulation Tools
• GUI for Animating a 3-D View (GUIDE)
About the 3-D Animation Example
View and Run the 3-D Globe GUI
• GUI to Interactively Explore Data in a Table (GUIDE)
• List Box Directory Reader (GUIDE)
• Access Workspace Variables from a List Box (GUIDE)
• A GUI to Set Simulink Model Parameters (GUIDE)
About the Simulink Model Parameters Example
View and Run the Simulink Parameters GUI
How to Use the Simulink Parameters GUI
Program the Slider and Edit Text Components
• An Address Book Reader (GUIDE)
About the Address Book Reader Example
View and Run the Address Book Reader GUI
Run the Address Book Reader GUI
Load an Address Book Into the Reader
The Contact Phone Number Callback
Page Through Address Book - Prev/Next
• Use a Modal Dialog Box to Confirm an Operation (GUIDE)
About the Modal Dialog Example
View and Run the Modal Dialog Box GUIs
Set Up the Close Confirmation Dialog
Set Up the GUI with the Close Button
• Time Data Updates from a GUI (GUIDE)
• Create and Run a Programmatic GUI
Create Figures for Programmatic GUIs
• Add Components to a Programmatic GUI
• Compose and Code GUIs with Interactive Tools
Set Positions of Components Interactively
Set Font Characteristics Interactively
• Set Tab Order in a Programmatic GUI
• Create Menus for a Programmatic GUI
• Create Toolbars for Programmatic GUIs
• Design Programmatic GUIs for Cross-Platform Compatibility
• Initialize a Programmatic GUI
• Examples: Program GUI Components
• Share Data Among a GUI's Callbacks
• GUI with Axes, Menu, and Toolbar
About the Axes, Menu, and Toolbar Example
View and Run the AxesMenuToolbar Code
Generate the Graphing Commands and Data
• GUI that Displays and Graphs Tabular Data
View and Run the tableplot Code
Set Up and Interact with the uitable
Handle Graphics Property Browser
Why Write Custom Applications?
Exchanging Data Files Between Platforms
Overview of matimport.c Example
Declare Variables for External Data
Read External Data into mxArray Data
Creating a MAT-File in Fortran
Building on Windows Operating Systems
Deploying MAT-File Applications
Limitations to Shared Library Support
Troubleshooting Shared Library Applications
Examples of Passing Data to Shared Libraries
Manually Converting Data Passed to Functions
Constructing a libpointer Object
Creating a Pointer to a Primitive Type
Creating a Pointer to a Structure
Passing a Pointer to the First Element of an Array
Putting a String into a Void Pointer
Memory Allocation for an External Library
Working with Structures Examples
Example of Passing a MATLAB Structure
Using the Structure as an Object
Introduction to Source MEX-Files
Overview of Creating a Binary MEX-File
Using Help Files with MEX-Files
Workspace for MEX-File Functions
Selecting a Compiler on Windows Platforms
Selecting a Compiler on UNIX Platforms
Overview of Building the timestwo MEX-File
Understanding MEX-File Problems
Compiler and Platform-Specific Issues
Custom Building on UNIX Systems
Custom Building on Windows Systems
Creating a MEX-File Using LAPACK and BLAS Functions
Preserving Input Values from Modification
Passing Arguments to Fortran Functions from C/C++ Programs
Passing Arguments to Fortran Functions from Fortran Programs
Handling Complex Numbers in LAPACK and BLAS Functions
Modifying the Function Name on UNIX Systems
MEX Uses 32-Bit API by Default
How to Upgrade MEX-Files to Use the 64-Bit API
Passing Two or More Inputs or Outputs
Passing Structures and Cell Arrays
Handling 8-, 16-, and 32-Bit Data
Manipulating Multidimensional Numerical Arrays
Calling Functions from C/C++ MEX-Files
Using C++ Features in MEX-Files
Debugging on the Microsoft Windows Platforms
Building Cross-Platform Applications
Specifying Constant Literal Values
Replacing fseek and ftell with 64-Bit Functions
Determining the Size of an Open File
Determining the Size of a Closed File
Using the Fortran %val Construct
Passing Two or More Inputs or Outputs
Calling Functions from Fortran MEX-Files
Debugging on Microsoft Windows Platforms
Building Cross-Platform Applications
What You Need to Build Engine Applications
Calling MATLAB Software from a C Application
Calling MATLAB Software from a C++ Application
Calling MATLAB Software from a Fortran Application
Attaching to an Existing MATLAB Session
Building and Running Engine Applications on Windows Operating Systems
Windows Engine Example engwindemo
Building and Running Engine Applications on UNIX Operating Systems
Files Required by Engine Applications
Debugging MATLAB Functions Used in Engine Applications
Benefits of the MATLAB Java Interface
Who Should Use the MATLAB Java Interface
To Learn More About Java Programming Language
Platform Support for JVM Software
Using a Different Version of JVM Software
Making Java Classes Available in MATLAB Workspace
Loading Java Class Definitions
Locating Native Method Libraries
Java Classes Contained in a JAR File
Saving and Loading Java Objects to MAT-Files
Finding the Public Data Fields of an Object
Accessing Private and Public Data
Determining the Class of an Object
Invoking Static Methods on Java Classes
Obtaining Information About Methods
Java Methods That Affect MATLAB Commands
How MATLAB Software Handles Undefined Methods
How MATLAB Software Handles Java Exceptions
Method Execution in MATLAB Software
How MATLAB Software Represents the Java Array
Creating an Array of Objects in MATLAB Software
Accessing Elements of a Java Array
Creating a New Array Reference
Creating a Copy of a Java Array
Conversion of MATLAB Argument Data
Passing Data to Overloaded Methods
Conversion of Java Return Types
Converting Objects to MATLAB Types
Description of Function phonebook
Description of Function pb_lookup
Description of Function pb_add
Description of Function pb_remove
Description of Function pb_change
Description of Function pb_listall
Description of Function pb_display
Description of Function pb_keyfilter
Benefits of the MATLAB .NET Interface
Why Use the MATLAB .NET Interface?
What's the Difference Between the MATLAB .NET Interface and MATLAB Builder NE?
Using a .NET assembly in MATLAB
To Learn More About the .NET Framework
Loading .NET Assemblies into MATLAB
What Classes Are in a .NET Assembly?
Using the delete Function on a .NET Object
How MATLAB Maps C# Property and Field Access Modifiers
Call .NET Methods with Optional Arguments
Calling .NET Extension Methods
Call .NET Properties That Take an Argument
How MATLAB Represents .NET Operators
Limitations to Support of .NET Methods
Limitations to Support of .NET Events
Handling Data Returned from a .NET Object
Accessing .NET Array Elements in MATLAB
Converting .NET Arrays to Cell Arrays
Limitations to Support of .NET Arrays
Call a .NET Delegate in MATLAB
Create a Delegate from a .NET Object Method
Create a Delegate Instance Bound to a .NET Method
Use .NET Delegates With the out and ref Type Arguments
Combine and Remove .NET Delegates
Calling a .NET Method Asynchronously
Limitations to Support of .NET Delegates
Iterate Through a .NET Enumeration
Use .NET Enumerations to Test for Conditions
Example - Read Special System Folder Path
Use Bit Flags with .NET Enumerations
Limitations to Support of .NET Enumerations
Work with Microsoft Word Documents Using .NET
Accessing Items in a .NET Collection
Convert a .NET Collection to a MATLAB Array
Display .NET Generic Methods Using Reflection
Create .NET Object From Constructor
View Information About .NET Object
Introduction to .NET Data Types
Use .NET Numeric Types in MATLAB
Do Not Use ClassName.PropertyName Syntax for Static Properties
Call .NET Methods That Use the out Keyword
Call .NET Methods That Use the ref Keyword
Call .NET Methods That Use the params Keyword
Create a Cell Array for Each System.Object
Create MATLAB Variables from the .NET Data
Call MATLAB Functions with MATLAB Variables
The MATLAB COM Automation Server
Registering Controls and Servers
Overview of MATLAB COM Client Examples
Example - Using Internet Explorer Program in a MATLAB Figure
Example - Grid ActiveX Control in a Figure
Example - Reading Excel Spreadsheet Data
MATLAB Client and In-Process Server
MATLAB Client and Out-of-Process Server
COM Implementations Supported by MATLAB Software
Client Application and MATLAB Automation Server
Client Application and MATLAB Engine Server
Identifying Objects and Interfaces
Setting the Value of a Property
Using Enumerated Values for Properties
Properties That Take Arguments
Exceptions to Using Implicit Syntax
Specifying Enumerated Parameters
Returning Multiple Output Arguments
Argument Callouts in Error Messages
Functions for Working with Events
Responding to Events - an Overview
Responding to Events - Examples
Writing Event Handlers as MATLAB File Subfunctions
Releasing COM Interfaces and Objects
Handling Data from a COM Object
Passing MATLAB Data to ActiveX Objects
Passing MATLAB SAFEARRAY to COM Object
Reading SAFEARRAY from a COM Object in MATLAB Applications
Displaying MATLAB Syntax for COM Objects
Using a MATLAB Application as an Automation Client
Connecting to an Existing Excel Application
Running a Macro in an Excel Server Application
Using Microsoft Forms 2.0 Controls
Using MATLAB Application as a DCOM Client
MATLAB COM Support Limitations
Connecting to an Existing MATLAB Server
Executing Commands in the MATLAB Server
Exchanging Data with the Server
Terminating the Server Process
Specifying a Shared or Dedicated Server
Using MATLAB Application as a DCOM Server
Example - Viewing Methods from a Visual Basic .NET Client
Example - Calling MATLAB Software from a Web Application
Example - Calling MATLAB Software from a C# Client
What You Need to Use Web Services with MATLAB
Typical Applications Using Web Services with MATLAB
How MATLAB Accesses Web Services
Example - createClassFromWsdl Function
Tools for Creating Web Services
Supported Serial Port Interface Standards
Using the Examples with Your Device
The Serial Port Interface Standard
Connecting Two Devices with a Serial Cable
Serial Port Signals and Pin Assignments
Finding Serial Port Information for Your Platform
Using Virtual USB Serial Ports
Configuring and Returning Properties
Configuring Properties During Object Creation
The Serial Port Object Display
Creating an Array of Serial Port Objects
Example - Introduction to Writing and Reading Data
Controlling Access to the MATLAB Command Line
Example - Writing and Reading Text Data
Example - Parsing Input Data Using textscan
Example - Introduction to Events and Callbacks
Event Types and Callback Properties
Responding To Event Information
Creating and Executing Callback Functions
Enabling Callback Functions After They Error
Example - Using Events and Callbacks
Signaling the Presence of Connected Devices
Controlling the Flow of Data: Handshaking
Example: Introduction to Recording Information
Creating Multiple Record Files
Example: Recording Information to Disk
Using Serial Port Objects on Different Platforms
• Examples
| On this page… |
|---|
Highlight Syntax to Help Ensure Correct Entries in the Command Window Avoid Mismatched Parentheses, Brackets, Braces, and Paired Keywords |
To help you find MATLAB elements, such as matching if/else statements, some entries appear in different colors in the Command Window. This is known as syntax highlighting. By default:
Keywords are blue.
Strings are purple.
Unterminated strings are maroon.

Except for errors, output in the Command Window does not appear with syntax highlighting.
To change syntax highlighting preferences, select File > Preferences > Editor/Debugger > Languages.
When you type code at the Command prompt or in the Editor, MATLABhelps you avoid mismatched delimiters, such as parenthesis, brackets, and braces. In addition, MATLAB indicates paired language keywords in the Editor. Paired language keywords include for, if, while, else, and end statements.
By default, MATLAB indicates matched and mismatched delimiters and paired language keywords as follows:
Type a closing delimiter—MATLAB briefly highlights the corresponding opening delimiter.
Type more closing delimiters than opening delimiters—MATLAB beeps.
Use the arrow keys to move the cursor over one delimiter—MATLAB briefly underlines both delimiters in a pair. If no corresponding delimiter exists, MATLAB puts a strike line through the unmatched delimiter.
If a matching delimiter exists, but it is not visible on the screen, a pop-up window appears and shows the line containing the matching delimiter. Click in the pop-up window to go to that line.

To change delimiter matching indicators, and when and if they appear:
Select File > Preferences > Keyboard.
Under Delimiter Matching, choose when you want MATLAB to notify you of matches and mismatches in pairs of delimiters.
Choose how you want MATLAB to indicate matches by selecting one of the following from the Show match with drop-down menu associated with your selection or selections in step 2:
Balance — The corresponding delimiter is highlighted briefly.
Underline — Both delimiters in the pair are underlined briefly.
Highlight — Both delimiters in the pair are highlighted briefly.
Choose how you want MATLAB to indicate mismatches by selecting one of the following from the Show mismatch with menu associated with your selection or selection sin step 2:
Beep — MATLAB beeps.
Strikethrough — The delimiter you typed is crossed out briefly.
None — There is no action.
MATLAB helps you complete the names of functions, models, MATLAB objects, files, folders, variables, structures, and Handle Graphics property names, which can help you to avoid typographical errors.
To complete names in the Command Window:
Select File > Preferences > Keyboard.
Under Tab completion, select Enable in Command Window, and Tab key narrows completions.
Click OK.
In the Command Window, type the first few characters of the name you want to complete, and then press the Tab key.
For MATLAB to complete a file or folder name, it must be on the search path or in the current folder. Variables and structures must be in the current workspace.
Do one the following, depending on how MATLAB responds in step 3.
| If MATLAB: | Then: |
|---|---|
| Completes the name you want | You are done. |
| Presents a list of possible matches | Use the arrow keys to select the name you want, and then press the Tab key. See Example of Name Completion for a Variable in the Command Window. In addition, you can:
|
| Completes the first part of a name that uses dot notation | At the command line, type a dot, and then press the Tab key. Repeat until the name is complete. |
| Completes one property of several | At the command prompt, type a comma and the first part of the next property, and then press the Tab key. Repeat for all properties you want to specify. See Example of Name Completion for Handle Graphics Properties. |
This example shows how to use tab completion for a variable name when there is more than one name that starts with the characters you type. The process is similar for other names that do not use dot notation.
Select File > Preferences > Keyboard.
Under Tab completion, select Enable in Command Window.
Click OK.
In the Command Window, create a variable, costs_march, by typing the following in the Command Window.
costs_march = 100;
Type cos, and then press the Tab key.

MATLAB lists all possible completions, including MATLAB functions and the variable name you created, costs_march.
Navigate the list of possible completions using the up and down arrow keys to find and highlight costs_march.
Choose costs_march by pressing the Tab key.
The Command Window displays costs_march.
At the command prompt, add arguments, and press Enter.
MATLAB runs the statement.
This example shows how to complete the name for a class folder. The steps for completing other names that use dot notation are similar.
Consider the containers package in the matlabroot folder. The containers package contains a Map @- folder and a Map.m file. The folder structure appears as follows:
+containers\@Map\Map.m
To use tab completion:
Select File > Preferences > Keyboard.
Under Tab completion, select Enable in Command Window.
Click OK.
In the Command Window, type edit cont, and then press Tab.
MATLAB displays a list from which to choose, such as the following.

Select containers, and then press Tab.
The Command Window displays edit containers.
At the command prompt, add a dot after containers, and then press Tab.
The Command Window displays:
edit containers.Map
.
At the command prompt, add a dot after Map, and then press Tab
MATLAB displays a new list.

Scroll down the list, select isvalid, and then press the Tab key.
The Command Window displays edit containers.Map.isvalid.
This example shows how to complete the names of MATLAB Handle Graphics properties using tab completion. The steps for completing properties for other objects that use dot notation are similar.
Select File > Preferences > Keyboard.
Under Tab completion, select Enable in Command Window.
Click OK.
In the Command Window, create a figure:
scrsz = get(0,'ScreenSize');
f=figure('Position',[1 scrsz(4)/2 scrsz(3)/2 scrsz(4)/2])Type set(f, 'pap , and then press the Tab key.
MATLAB displays

Type u, and then press the Tab key.
MATLAB completes the property, including the closing quote:
set(f, 'paperunits'
Type , 'c, and then press the Tab key.
Because centimeters is the only possible completion, MATLAB automatically completes the property and displays:
set(f, 'paperUnits', 'centimeters'
Complete the command by typing a closing parenthesis at the command prompt.
As you enter a function in the Command Window or Editor, syntax hints open in a pop-up window to display allowable input arguments for a function. These function hints appear for both MATLAB installed functions and functions you create. The syntax comes from the function definition statement (first executable line) in the MATLAB program file. That file must be on the search path or in the current folder.
Be aware that:
For an overloaded function name, the syntax for the method includes valid objects of the method currently in the workspace.
MATLAB cannot always determine the appropriate hints correctly. Some allowable arguments may not appear, or could be in black text when they should be blue.
To use function syntax hints in the Command Window, follow these steps, as shown for the size function:
Ensure function hints are enabled.
Select File > Preferences > Keyboard, and then setting the options for Function hints.
Type any output arguments and the equal sign. For example:
[m]=
Type the function name and the opening (left) parenthesis, and then pause. For example:
size(
A yellow window appears, displaying the syntax options for the function.

Type a variable name for the first input argument. You can type a variable for any argument that appears in blue.
In this example, for the input argument X, type your variable:
my_data
Enter more arguments:
Type a comma after the argument you just entered.
The displayed syntax options change, based on the argument you just entered.
For this example, only the X,dim option displays. dim is blue now, because you can enter it.

Type the next input argument. It can be any argument that is blue.
For example, to run size for the third dimension, enter 3 for dim.
Continue entering more input arguments in the same way.
When you finish entering arguments, type the closing (right) parenthesis.
The pop-up window closes.
![]() | Command Window Code and Output Display | Find Text in the Command Window | ![]() |

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 |


