null  User manual

MATLAB
The Language of Technical Computing
Computation
Visualization
Programming
MATLAB 5.1 New Features
How to Contact The MathWorks:
☎
508-647-7000
Phone
508-647-7001
Fax
The MathWorks, Inc.
24 Prime Park Way
Natick, MA 01760-1500
Mail
http://www.mathworks.com
Web
Anonymous FTP server
Newsgroup
FAX
✉
ftp.mathworks.com
comp.soft-sys.matlab
@
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
Technical support
Product enhancement suggestions
Bug reports
Documentation error reports
Subscribing user registration
Order status, license renewals, passcodes
Sales, pricing, and general information
MATLAB 5.1 New Features
 COPYRIGHT 1984 - 1997 by The MathWorks, Inc. All Rights Reserved.
The software described in this document is furnished under a license agreement. The software may be used
or copied only under the terms of the license agreement. No part of this manual may be photocopied or reproduced in any form without prior written consent from The MathWorks, Inc.
U.S. GOVERNMENT: If Licensee is acquiring the software on behalf of any unit or agency of the U. S.
Government, the following shall apply:
(a) for units of the Department of Defense:
RESTRICTED RIGHTS LEGEND: Use, duplication, or disclosure by the Government is subject to restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in Technical Data and Computer Software Clause
at DFARS 252.227-7013.
(b) for any other unit or agency:
NOTICE - Notwithstanding any other lease or license agreement that may pertain to, or accompany the
delivery of, the computer software and accompanying documentation, the rights of the Government
regarding its use, reproduction and disclosure are as set forth in Clause 52.227-19(c)(2) of the FAR.
Contractor/manufacturer is The MathWorks Inc., 24 Prime Park Way, Natick, MA 01760-1500.
MATLAB, Simulink, Handle Graphics, and Real-Time Workshop are registered trademarks and Stateflow
and Target Language Compiler are trademarks of The MathWorks, Inc.
Other product or brand names are trademarks or registered trademarks of their respective holders.
Printing History: May 1997
First printing
Contents
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . vii
Help Desk . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . vii
MATLAB Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . viii
MATLAB 5.1 Enhancements
1
Who Should Read This Chapter? . . . . . . . . . . . . . . . . . . . . . . . 1-2
Upgrading from MATLAB 5.0 to MATLAB 5.1? . . . . . . . . . . . . 1-2
Upgrading from MATLAB 4 to MATLAB 5.1? . . . . . . . . . . . . . . 1-2
What’s New in MATLAB 5.1? . . . . . . . . . . . . . . . . . . . . . . . . . . .
Enhancements to MATLAB . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Upgrades to Application Toolboxes, Simulink, and
Real-Time Workshop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
New Products . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Online Documentation for Associated Products . . . . . . . . . . . .
For Additional Product Information . . . . . . . . . . . . . . . . . . . . . .
1-3
1-3
1-4
1-5
1-5
1-6
Language and Development Environment Enhancements 1-7
find Returns Empty Matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-7
Multibyte Character Support . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-7
Removal of MS-Windows TCP/IP Issues . . . . . . . . . . . . . . . . . . 1-7
Notebook Support for Office 97 . . . . . . . . . . . . . . . . . . . . . . . . . . 1-7
PC Editor/Debugger . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-8
Editing Arrays on the Macintosh . . . . . . . . . . . . . . . . . . . . . . . . 1-8
The Path Browser on the Macintosh . . . . . . . . . . . . . . . . . . . . . 1-9
Macintosh Debugger . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-10
Handle Graphics Enhancements . . . . . . . .
Scatter Plot Functions Added . . . . . . . . . . . .
X-Windows Support for uisetcolor . . . . . . . .
Previously Undocumented Functions . . . . . .
Printing Patches and Surfaces . . . . . . . . . . .
.......
.......
.......
.......
.......
.......
.......
.......
.......
.......
1-11
1-11
1-11
1-11
1-11
i
TIFF and JPEG Device Drivers . . . . . . . . . . . . . . . . . . . . . . . . 1-12
TIFF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-12
JPEG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-13
TIFF Preview Images for Encapsulated PostScript . . . . . . 1-15
Alternate Method on the Macintosh . . . . . . . . . . . . . . . . . . . . . 1-15
API Enhancement for Windows NT . . . . . . . . . . . . . . . . . . . . 1-16
Setting Up the Compiler Location . . . . . . . . . . . . . . . . . . . . . . 1-16
API Enhancements for the Macintosh . . . . . . . . . . . . . . . . . . 1-17
Installation Notes for Using CodeWarrior 11 with
the MATLAB API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-17
Using CodeWarrior 10 and 11 with the MATLAB API . . . . . . 1-17
Stateflow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-19
Addition to the Simulink Modeling Environment . . . . . . . . . . 1-19
Stateflow Coder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-19
Mapping Toolbox . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-20
MATLAB 5.0 Enhancements
2
Who Should Read This Chapter? . . . . . . . . . . . . . . . . . . . . . . . . 2-2
Upgrading from MATLAB 5.0 to MATLAB 5.1? . . . . . . . . . . . . 2-2
Upgrading from MATLAB 4 to MATLAB 5.1? . . . . . . . . . . . . . . 2-2
MATLAB 5.0 Enhancements . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Enhanced Programming and Application Development Tools .
New Data Types, Structures, and Language Features . . . . . . .
Faster, Better Graphics and Visualization . . . . . . . . . . . . . . . . .
More Mathematical and Data Analysis Tools . . . . . . . . . . . . . .
Enhancements to Application Toolboxes and to Simulink . . . .
ii
Contents
2-3
2-3
2-4
2-4
2-5
2-5
New Data Constructs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-6
Multidimensional Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-6
Cell Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-8
Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-8
MATLAB Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-9
Character Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-10
Programming Capabilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-11
Flow-Control Improvements . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-11
M-File Programming Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-13
New and Enhanced Language Functions . . . . . . . . . . . . . . .
Subscripting and Assignment Enhancements . . . . . . . . . . . . .
Integer Bit Manipulation Functions . . . . . . . . . . . . . . . . . . . . .
Dimension Specification for Data Analysis Functions . . . . . . .
Wildcards in Utility Commands . . . . . . . . . . . . . . . . . . . . . . . .
Empty Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2-15
2-17
2-17
2-18
2-19
2-19
New Data Analysis Features . . . . . . . . . . . . . . .
Higher-Dimension Interpolation . . . . . . . . . . . . .
griddata Based on Delaunay Triangulation . . . .
Set Theoretic Functions . . . . . . . . . . . . . . . . . . . .
...........
...........
...........
...........
2-21
2-22
2-22
2-22
New and Enhanced Handle Graphics Features . . . . . . . . .
Plotting Capabilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Data Visualization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Graphics Presentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Lighting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
print Command Revisions . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Image Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2-24
2-24
2-25
2-27
2-29
2-30
2-31
New and Enhanced Handle Graphics Object Properties . 2-35
Improvements to Graphical User Interfaces (GUIs) . . . . . 2-44
General GUI Enhancements . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-44
Guide . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-45
Enhanced Application Program Interface (API) . . . . . . . . . 2-46
New Fundamental Data Type . . . . . . . . . . . . . . . . . . . . . . . . . . 2-46
New Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-46
iii
Enhanced Debugging Support . . . . . . . . . . . . . . . . . . . . . . . . . . 2-47
Enhanced Compile Mechanism . . . . . . . . . . . . . . . . . . . . . . . . . 2-47
MATLAB 4 Feature Unsupported in MATLAB 5.0 . . . . . . . . . 2-47
New Platform-Specific Features . . . . . . . . . . . . . . . . . . . . . . .
MS Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Macintosh . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
UNIX Workstations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3
2-48
2-48
2-52
2-57
Upgrading to MATLAB 5.1
Upgrading from MATLAB 4 to MATLAB 5.1 . . . . . . . . . . . . . . 3-2
Converting M-Files to MATLAB 5.1 . . . . . . . . . . . . . . . . . . . . . 3-3
Converting MATLAB 4 External Interface Programs to
the MATLAB 5.1 Application Program Interface . . . . . . . .
General Considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Windows Considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
UNIX Considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Macintosh Considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
VMS Considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Conversion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Recoding for MATLAB 5.1 Compliance . . . . . . . . . . . . . . . . . .
iv
Contents
3-18
3-18
3-21
3-22
3-22
3-22
3-23
3-27
List of Tables
Table 2-1:
Table 2-2:
Table 2-3:
Table 2-4:
Table 2-5:
Table 2-6:
Table 2-7:
Table 2-8:
Table 2-9:
Table 2-10:
Table 2-11:
Table 2-12:
Table 2-13:
Table 2-14:
Table 2-15:
Table 2-16:
Table 2-17:
Table 2-18:
Table 2-19:
Table 2-20:
Table 2-21:
Table 2-22:
Table 2-23:
Table 2-24:
Table 2-25:
Table 2-26:
Table 2-27:
Table 2-28:
Table 2-29:
Table 2-30:
Table 2-31:
Table 2-32:
Table 2-33:
Table 2-34:
Table 2-35:
Table 2-36:
Table 2-37:
Table 2-38:
Table 2-39:
Table 2-40:
Table 2-41:
New Multidimensional Array Functions . . . . . . . . . . . . . . . . 2-7
New Cell Array Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-8
New Structure Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-9
New Character String Functions . . . . . . . . . . . . . . . . . . . . . 2-10
New Object-Oriented Functions . . . . . . . . . . . . . . . . . . . . . . 2-11
New Flow Control Commands . . . . . . . . . . . . . . . . . . . . . . . 2-12
New Logical Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-12
New Programming Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-13
New Elementary and Specialized Math Functions . . . . . . . 2-15
New Time and Date Functions . . . . . . . . . . . . . . . . . . . . . . . 2-15
New Ordinary Differential Equation Functions . . . . . . . . . 2-16
New Matrix Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-16
New Methods for Sparse Matrices . . . . . . . . . . . . . . . . . . . . 2-16
New Bitwise Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-17
New Statistical Data Analysis Functions . . . . . . . . . . . . . . 2-21
New Interpolation Functions . . . . . . . . . . . . . . . . . . . . . . . . 2-22
New Set Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-22
New and Enhanced Plotting Capabilities . . . . . . . . . . . . . . 2-24
New Graph Annotation Functions . . . . . . . . . . . . . . . . . . . . 2-25
New Three-Dimensional Plotting Functions . . . . . . . . . . . . 2-25
New Triangular Mesh and Surface Functions . . . . . . . . . . . 2-26
New Contour Plot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-26
New Figure and Axis Color Control . . . . . . . . . . . . . . . . . . . 2-28
New Colormaps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-28
New Figure Window Creation and Control Command . . . . 2-29
print Command Device Options . . . . . . . . . . . . . . . . . . . . . . 2-30
Properties of All Graphics Objects . . . . . . . . . . . . . . . . . . . . 2-35
Axes Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-36
Figure Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-37
Image Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-38
Light Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-38
Line Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-39
Patch Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-39
Root Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-40
Surface Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-41
Text Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-42
Uicontrol Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-42
Uimenu Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-43
New GUI Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-44
New Program Execution Functions . . . . . . . . . . . . . . . . . . . 2-45
Guide Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-45
v
Table
Table
Table
Table
Table
vi
Contents
3-1:
3-2:
3-3:
3-4:
3-5:
Language Changes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-3
Obsolete Language Functions . . . . . . . . . . . . . . . . . . . . . . . 3-10
Graphics Function Changes . . . . . . . . . . . . . . . . . . . . . . . . . 3-12
Graphics Property Changes . . . . . . . . . . . . . . . . . . . . . . . . . 3-14
Recoding MATLAB 4 Functions for MATLAB 5.1
Compliance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-28
Introduction
Introduction
MATLAB 5.1 is a new release of MATLAB® that builds on MATLAB 5.0. We’ve
listened to your requests for new features – via telephone, e-mail, and at
conferences, and have carefully used them to design this new version. We have
combined these requests with exciting innovations to bring you MATLAB 5.1.
This book
• Describes new features and enhancements in MATLAB 5.1 (including
features were new in MATLAB 5.0)
• Provides guidelines for upgrading from MATLAB 4 to MATLAB 5.1 (and
from MATLAB 5.0 to MATLAB 5.1)
If you are familiar with MATLAB 5.0, read this guide and the MATLAB
Installation Guide, and then use the online documentation provided with
MATLAB 5.1.
If you are upgrading from MATLAB 4, you should read this guide first. Go on
to Using MATLAB and Using MATLAB Graphics for more details on any new
feature. If you encounter a new MATLAB function in this book and want to
learn more, consult the online MATLAB Function Reference.
If you are a new MATLAB user, you should begin with Getting Started with
MATLAB, which introduces you to MATLAB’s capabilities as a programming
and visualization language.
Help Desk
MATLAB 5.1 includes the MATLAB Help Desk, an enhanced Help facility that
provides access to online help topics, online reference materials, electronic
documentation, and World Wide Web pages through a Web browser. You do not
need to be connected to the Internet to use this facility.
The Help Desk should be used with Netscape Navigator Release 2.0 or 3.0, or
Microsoft Internet Explorer 3.0.
You can access this facility on all platforms via the helpdesk command. On the
PC and Macintosh, on the Command Window toolbar, you can also use the
Help menu (to bring up the Help Desk) or the ? icon (to bring up the help
window for displaying MATLAB help text.
vii
Related MATLAB Commands
• help displays MATLAB help text in the command window.
• helpwin opens a window and displays MATLAB help text.
• doc displays the reference documentation page for the specified function.
MATLAB Documentation
The MATLAB documentation set has been rewritten, expanded, and divided
into several volumes for ease of use. The set includes online help, as well as
hypertext-based and printed manuals. The online MATLAB Function
Reference is a compendium of all MATLAB language, mathematical, and
graphics functions. You can access this documentation from the MATLAB Help
Desk. Under MATLAB Functions you can click on either by Subject or by
Index to display the functions in the Function Reference. For a complete list
viii
Introduction
of all MEX-file, MAT-file, and Engine routines, choose Application Program
Interface on the Help Desk. The rest of the documentation set, described
below, is available in PDF format, accessible via Adobe’s Acrobat Reader (some
of those manuals are also available in HTML format).
If You Are Upgrading from MATLAB 5.0 to 5.1
The online documentation is augmented with a set of printed documents. The
following manuals are shipped to customers upgrading from MATLAB 5.0 to
MATLAB 5.1:
• MATLAB 5.1 New Features, which summarizes new features and provides
information useful in making the transition from MATLAB 4 to MATLAB
5.1.
• MATLAB Installation Guide, which describes how to install MATLAB on
your platform.
• Late-Breaking News for the MATLAB 5.1 Product Family, which contains
information that became available after the preparation of the rest of the
documentation set.
If You Are a New MATLAB Customer or Upgrading from MATLAB 4 to 5.1
New MATLAB customers and MATLAB 4 customers who are upgrading to
MATLAB 5.1 receive, in addition to the above three manuals, the printed
documents listed below. (Note that these manuals were already shipped to
customers who received MATLAB 5.0).
• Getting Started with MATLAB, an introductory document describing the
fundamentals of MATLAB.
• Using MATLAB, which explains how to use MATLAB as both a
programming language and a command-line application.
• Using MATLAB Graphics, which describes how to use MATLAB’s graphics
and visualization tools.
• MATLAB Application Program Interface Guide, which explains how to write
C or Fortran programs that interact with MATLAB.
• Building GUIs with MATLAB, which describes Guide, a Graphical User
Interface (GUI) design tool.
• MATLAB Notebook User’s Guide, which describes the use of Microsoft Word
as an interface to MATLAB.
ix
If one or more of the printed documents is unavailable to you, you can locate an
online version of the same document via the Help Desk.
Additionally, command line ASCII help and an extensive library of
demonstration programs provide instant online reference information about
MATLAB commands and demonstrate MATLAB features.
x
1
MATLAB 5.1
Enhancements
Who Should Read This Chapter? . . . . . . . . . . . 1-2
What’s New in MATLAB 5.1? . . . . . . . . . . . . . 1-3
Language and Development Environment
Enhancements . . . . . . . . . . . . . . . . . 1-7
Handle Graphics Enhancements . . . . . . . . . . . 1-11
TIFF and JPEG Device Drivers
. . . . . . . . . . . 1-12
TIFF Preview Images for Encapsulated PostScript
. . 1-15
API Enhancement for Windows NT . . . . . . . . . . 1-16
API Enhancements for the Macintosh
Stateflow
. . . . . . . . 1-17
. . . . . . . . . . . . . . . . . . . . . 1-19
Mapping Toolbox . . . . . . . . . . . . . . . . . . 1-20
1
MATLAB 5.1 Enhancements
Who Should Read This Chapter?
Upgrading from MATLAB 5.0 to MATLAB 5.1?
If you are upgrading from MATLAB 5.0 to MATLAB 5.1, you should read
Chapter 1. You can skip Chapter 2, which documents features added in
MATLAB 5.0, which were already documented in the MATLAB 5.0
documentation.
You should also read Chapter 3, which includes information about converting
MATLAB 5.0 applications to MATLAB 5.1.
Note: Chapter 3 expands upon conversion issues discussed in the MATLAB 5
New Features Guide; the additional information is highlighted with change
bars in the left margin.
Upgrading from MATLAB 4 to MATLAB 5.1?
If you are upgrading from MATLAB 4 to MATLAB 5.1, you should read
Chapter 1 and Chapter 2, which document features added in MATLAB 5.1 and
features introduced with MATLAB 5.0 and carried forward to MATLAB 5.1. In
addition, you should read Chapter 3, which documents how to convert
MATLAB 4 applications to MATLAB 5.1.
1-2
What’s New in MATLAB 5.1?
What’s New in MATLAB 5.1?
The main purpose of the MATLAB 5.1 release is to complete upgrades to the
5.0 level of the entire set of toolboxes and blocksets, and to introduce the
Stateflow product. However, there are also a number of small but useful
enhancements to MATLAB provided with this release.
Enhancements to MATLAB
MATLAB 5.1 adds several enhancements to the MATLAB language and
development environment, Handle Graphics®, printing, and the Application
Program Interface (API). These features are documented fully in the MATLAB
5.1 online documentation.
The language and development environment enhancements include:
• find returns an empty matrix (page 1-7)
• Several PC enhancements:
- Removal of MS-Windows TCP/IP requirement (page 1-7)
- Notebook support for Office 97 (page 1-7)
- Multibyte character support (page 1-7
- PC Editor/Debugger icons changed (page 1-8)
• Several Macintosh enhancements:
- Editing arrays on the Macintosh (page 1-8)
- Enhancements to the Macintosh Path Browser (page 1-9)
- Enhancements to the Macintosh Debugger (page 1-10)
The Handle Graphics and printing enhancements include:
• Scatter plot functions added (page 1-11)
• X-Windows support for uisetcolor (page 1-11)
• Patch and surface printing enhancements (page 1-11)
• TIFF and JPEG device drivers added (page 1-12)
• TIFF preview images for Encapsulated Postscript (page 1-15)
1-3
1
MATLAB 5.1 Enhancements
The Application Program Interface enhancements include:
• Setting up the compiler location for Windows NT (page 1-16)
• Support for CodeWarrior 11 for the Macintosh (page 1-17)
MATLAB 5.1 also fixes bugs from earlier releases either reported by customers
or found through additional internal testing.
Upgrades to Application Toolboxes, Simulink, and
Real-Time Workshop
MATLAB 5.1 completes the upgrades to the entire set of toolboxes. Simulink
and Real-Time Workshop were also upgraded. Significant upgrades introduced
with MATLAB 5.1 include:
• Simulink 2.1
• Real-Time Workshop 2.1
• DSP Blockset 2.0
• Fixed-Point Blockset 1.0.2
• Image Processing Toolbox 2.0
• Symbolic Math Toolboxes 2.0
• Communications Toolbox 1.2
See the Simulink 2.1 New Features Guide and the individual toolbox User’s
Guides for information about enhancements to these products.
NOTE: The MATLAB Compiler and the MATLAB C and C++ Math Libraries
are not supported for Version 5.1. Those products work with MATLAB 4.
New Products
In addition to these toolboxes, two new products are now available with
MATLAB 5.1:
• Stateflow™ 1.0
• Mapping Toolbox 1.0
1-4
What’s New in MATLAB 5.1?
Stateflow™ and the Mapping Toolbox are described in more detail starting on
page 1-19.
Online Documentation for Associated Products
You can access via the Help Desk online documentation for Stateflow,
Real-Time Workshop, and several toolboxes and blocksets. The online
documentation is available in one or both of these formats: PDF, accessible via
Adobe Acrobat Reader, and HTML, via either Netscape Navigator Release 3.0
or Microsoft Internet Explorer 3.0.
The following associated products have PDF and HTML online documentation:
• Stateflow
• Control Systems Toolbox
• Signal Processing Toolbox
• Symbolic Math Toolboxes
• DSP Blockset
The following associated products have PDF, but not HTML, online
documentation:
• Communications Toolbox
• Fixed-Point Blockset
• Image Processing Toolbox
• Mapping Toolbox (User’s Guide only)
• Nonlinear Control Design Blockset
• Fuzzy Logic Toolbox
• Real-Time Workshop®
• Wavelet Toolbox
1-5
1
MATLAB 5.1 Enhancements
For Additional Product Information
To get information about all the products from The MathWorks, type at the
MATLAB command line
tour
You can also access additional product information from The MathWorks Web
site.
1-6
Language and Development Environment Enhancements
Language and Development Environment Enhancements
find Returns Empty Matrix
The find function now returns an empty matrix if nothing is found. Previously
it returned [0,1].
Multibyte Character Support
On the PC, MATLAB 5.1 provides support for multibyte characters (including
Kanji) for data.
This feature allows you to use multibyte characters in MATLAB strings. You
can also use multibyte characters in Handle Graphics property values and
Simulink blocks.
Note that you cannot use multibyte characters in variable, file, or function
names. Also, multibyte text may not be machine independent.
Removal of MS-Windows TCP/IP Issues
MATLAB 5.0 for Microsoft Windows 95 required the use of TCP/IP networking
software even for non-networked installations. For MATLAB 5.1 this
requirement has been removed. The portions of the MATLAB user interface
that depended upon TCP/IP have been recoded to use ActiveX.
Notebook Support for Office 97
MATLAB 5.1 provides Notebook support for Microsoft Office 97.
Note: The MATLAB 5.1 Notebook is fully supported for Windows NT with
Microsoft Office 97. However, for Windows 95, due to an Office 97 problem,
printing a Notebook document that includes an imported graphic may not
print correctly. See “OFF97: Imported EMF Files Are Not Printed Correctly”
in the online Microsoft Knowledge Base for details.
1-7
1
MATLAB 5.1 Enhancements
PC Editor/Debugger
For MATLAB 5.1 the PC Editor/Debugger has new debugging icons on the
toolbar. The debugging operations are the same as for MATLAB 5.0. The new
debugging icons on the toolbar are:
Toolbar
Button
Description
Equivalent
Command
Set/Clear Breakpoint: set or clear a
breakpoint at the line containing the cursor.
dbstop/
dbclear
Clear All Breakpoints: clear all breakpoints
dbclear all
that are currently set.
Step In: execute the current line of the M-file
and if the line is a call to another function, step
into that function.
dbstep in
Single Step: execute the current line of the
M-file.
dbstep
Continue: continue execution of M-file until
dbcont
completion or until another breakpoint is
encountered.
Quit Debugging: exit the debugging state.
dbquit
Editing Arrays on the Macintosh
MATLAB 5.1 provides a new capability that allows you to view and edit
two-dimensional real and complex double arrays, row vector character arrays,
and row or column vector cell arrays of strings. If the Array Editor does not
support a variable type, double-clicking on the variable in the Workspace
Browser displays the variable in the Command Window. This tool can be
especially useful when debugging M-functions using the M-file Debugger.
1-8
Language and Development Environment Enhancements
For numeric arrays, the pull-down menu allows you to change the format of the
output display as if you were using the format command.
The Path Browser on the Macintosh
Add directory to end of path
Insert above selection or at top of path
Remove directory from path
Folder
selection
Current directory
Files in current
directory
Directories on search path
Types of files
to display
Revert to default Save current path
path setting
1-9
1
MATLAB 5.1 Enhancements
At this release, if you change the path from the Command Window, the Path
Browser’s contents update automatically. The Refresh button has been
removed from the Path Browser.
If you have checked the Add subfolders box, all subfolders of the selected
directory will be added to the path as well.
Macintosh Debugger
For MATLAB 5.1 the Debugger provides a new operation, Step Out, which is
represented by a new icon on the debugger toolbar. The full set of debugging
icons is:
Toolbar
Button
Description
Equivalent
Command
Single Step: execute the current line of
dbstep
the M-file.
Step In: execute the current line of the
M-file and if the line is a call to another
function, step into that function.
dbstep in
Step Out: continue execution until a
return to the calling function is
encountered.
Continue: continue execution of M-file
dbcont
until completion or until another
breakpoint is encountered.
Quit Debugging: exit the debugging
state.
dbquit
The 5.1 Debugger also introduces the Go Until Here menu item on the Debug
menu. If you place the cursor at a specific line and choose the menu item,
execution continues until that line is reached. Option-click on the breakpoint
marker next to a line to execute a shortcut for this operation.
1-10
Handle Graphics Enhancements
Handle Graphics Enhancements
MATLAB 5.1 provides some new Handle Graphics functions.
Scatter Plot Functions Added
MATLAB supports two new functions, scatter and scatter3, which enable
you to create two-dimensional and three-dimensional scatter plots. Each
function allows you to specify the style, size, and color of the marks used to
create the scatter diagrams.
See the online MATLAB Function Reference for more information about these
functions.
X-Windows Support for uisetcolor
The uisetcolor function is now supported on X-Windows systems.
Previously Undocumented Functions
These two functions existed in MATLAB 5.0, with command line help, but were
not documented in the MATLAB 5.0 online reference documentation:
• pagedlg – Dialog box to set page layout properties for printing Figures.
• printdlg – Dialog box to manage printing of Figures.
Printing Patches and Surfaces
You can now print texture-mapped patches and surfaces (this did not work in
Version 5.0).
Also, printing interpolated patches and surfaces is more efficient than in
Version 5.0.
1-11
1
MATLAB 5.1 Enhancements
TIFF and JPEG Device Drivers
MATLAB 5.1 includes new built-in device drivers for producing TIFF (Tagged
Image File Format) and JPEG (Joint Photographic Experts Group) graphics
files from MATLAB figures. These drivers are available on all platforms.
This table summarizes the command-line switches for these drivers:
Device
Description
–dtiff
TIFF with packbit compression
–dtiffnocompression
TIFF with no compression
–djpeg
Baseline JPEG, quality level 75
–djpegnumber
Baseline JPEG, quality level specified by number
Note that these drivers work with MATLAB figures only. You cannot use these
drivers to print Simulink models.
This section summarizes how to use these drivers with the print command.
TIFF
To produce a TIFF file from a MATLAB figure, use the –dtiff switch. For
example, this command produces a TIFF file named newplot.tif from the
current figure:
print –dtiff newplot.tif
You can use the –r option in conjunction with the –dtiff switch to specify the
resolution of the output. For example:
print –dtiff –r100 newplot.tif
If you do not specify the resolution, MATLAB uses the default resolution of 150
dots per inch.
Note that you must specify a filename, because TIFF files cannot be sent
directly to a printer. If you omit the filename, MATLAB assigns the file a name,
such as figure1.tif. If you specify a filename that does not include the .tif
extension, MATLAB appends the extension automatically.
1-12
TIFF and JPEG Device Drivers
The TIFF files that MATLAB produces are 24-bit truecolor bitmaps. MATLAB
renders these graphics using the Z-buffer renderer, regardless of the setting of
figure Renderer property. If you use the –painters switch with the print
command, the switch is ignored.
Compression
The TIFF output produced by –dtiff uses packbit compression, a lossless
compression scheme that is supported by virtually all applications that can
import TIFF graphics. If you need to import a TIFF file into an application that
does not read packbit-compressed TIFF, use the –dtiffnocompression switch
to produce an uncompressed TIFF file. (You can abbreviate this switch to
–dtiffn.) For example:
print –dtiffn –r100 newplot.tif
An uncompressed TIFF file is often much larger than the same file compressed.
For certain plots, the uncompressed file may be more than 10 times the size of
the compressed file. (The actual ratio will vary. The size of an uncompressed
file depends only on the resolution and the width and height values in the
PaperPosition figure property; the size of the compressed file also depends on
the content of the figure.)
JPEG
To produce a JPEG file from a MATLAB figure, use the –djpeg switch. For
example, this command produces a JPEG file named newplot.jpg from the
current figure:
print –djpeg newplot.jpg
You can you use the –r option in conjunction with the –djpeg switch to specify
the resolution of the output. For example:
print –djpeg –r100 newplot.jpg
If you do not specify the resolution, MATLAB uses the default resolution of 150
dots per inch.
Note that you must specify a filename, because JPEG files cannot be sent
directly to a printer. If you omit the filename, MATLAB assigns the file a name,
such as figure1.jpg. If you specify a filename that does not include the .jpg
extension, MATLAB appends the extension automatically.
1-13
1
MATLAB 5.1 Enhancements
The JPEG files that MATLAB produces are 24-bit truecolor bitmaps. MATLAB
renders these graphics using the Z-buffer renderer, regardless of the setting of
figure Renderer property. If you use the –painters switch with the print
command, the switch is ignored.
Compression
JPEG files use a lossy compression scheme that compresses files dramatically
with relatively little loss of information. This scheme enables you to make
tradeoffs between file size and quality, by specifying a quality level between 0
(minimum quality, maximum compression) and 100 (maximum quality,
minimum compression). By default, –djpeg uses a quality level of 75; however,
you can use a different level by appending the value to the device name. For
example, this command produces a JPEG file with a quality level of 50:
print –djpeg50 –r100 newplot.jpg
Even at the highest quality level, JPEG files are often highly compressed. In
fact, depending on the figure, a JPEG file with a quality level of 100 may be
considerable smaller than a packbit-compressed TIFF file of the same figure.
1-14
TIFF Preview Images for Encapsulated PostScript
TIFF Preview Images for Encapsulated PostScript
MATLAB 5.1 can produce TIFF preview images for Encapsulated PostScript
(EPS) files. To produce a TIFF preview, use the –tiff switch. For example, this
command creates an EPS file called newplot.eps that contains a TIFF
preview:
print –deps –tiff newplot.eps
The preview image has a resolution of 72 dots per inch, and the colors in the
preview match the colors in the EPS file. MATLAB creates the EPS with a loose
bounding box (i.e., white space around the figure), so that the size and position
of the preview image match the EPS. There may be some differences between
the EPS and the TIFF preview, however, because the preview is always
rendered using Z-buffer, while the EPS may be rendered with painter’s
algorithm.
The –tiff switch works on all platforms, and you can view the resulting
preview image within any application that can display TIFF graphics.
Alternate Method on the Macintosh
On Macintosh systems, you can also specify a TIFF preview image by selecting
Save As from the File menu of the figure window. In the dialog box, use the
File Type pop-up menu to select an EPS format, and then select TIFF from
the Preview pop-up menu.
Also on Macintosh systems, if you use the print command to create an EPS file
and you do not use the –tiff switch, the file is created with a PICT preview.
On other platforms, no preview is created.
1-15
1
MATLAB 5.1 Enhancements
API Enhancement for Windows NT
Setting Up the Compiler Location
The mex script supports a new switch, setup, that allows you to configure the
default options file, mexopts.bat, for your system C compiler. This eliminates
the need to reinstall MATLAB if you change compilers for your environment.
You can run the setup option from either the MATLAB or DOS command
prompt, and it can be called anytime to configure the options file.
Executing the setup option presents a list of compilers whose options files are
currently shipped in the bin subdirectory of MATLAB. This example shows
how to select the Microsoft Visual C++ compiler:
C:\mex –setup
C compilers
[1] Microsoft Visual C++
[2] Borland C/C++
[3] Watcom C/C++
Fortran compilers
[4] Microsoft Powerstation
[0] None
compiler: 1
If the selected compiler has more than one options file (due to more than one
version of the compiler), you are asked for a specific version. For example,
Which version
[1] 4.x
[2] 5.x
version: 1
Finally, you are asked to enter the location of your compiler:
Please enter the location of your C compiler c:\msdev
1-16
API Enhancements for the Macintosh
API Enhancements for the Macintosh
Installation Notes for Using CodeWarrior 11 with
the MATLAB API
MATLAB 5.1 supports CodeWarrior 10. CodeWarrior 11 is supported with the
limitations described below. Previous versions of CodeWarrior are not
supported.
In CodeWarrior 11, Metrowerks introduced a new ANSI C library, known as
the Metrowerks Standard Library (MSL). Based on difficulties we have had in
upgrading to MSL, and from similar USENET reports of MSL bugs, we have
decided to postpone MATLAB API (Application Program Interface) support for
MSL until a future version of CodeWarrior.
To use CodeWarrior 11 to generate MEX-files and/or MAT applications, you
must install the old CodeWarrior libraries and header files. These files are the
same as those shipped with previous versions of CodeWarrior, and can be found
on the CodeWarrior 11 CD-ROM in the folder
CW11 Gold Tools:Metrowerks CodeWarrior:(Obsolete ANSI Libraries):
The names of the folders within (Obsolete ANSI Libraries) indicate the
CodeWarrior folder to which their contents should be copied.
Using CodeWarrior 10 and 11 with the MATLAB API
The instructions below supersede the instructions for building MAT-file
programs when using CodeWarrior 10 and 11 that are given in Chapter 4 of the
MATLAB 5 Application Program Interface Guide.
Building Applications on the Power Macintosh and 68K Macintosh
To build applications that use the MAT API, start with a project made from the
stationery MATLAB_API_App.PPC.proj (for Power Macintoshes) or
MATLAB_API_App.68k.proj (for 68K Macintoshes) in the
<MATLAB>:extern:src: folder. Then, make these modifications to your project:
1 In the Access Paths preference panel, add the folder
<MATLAB>:extern:include: to the User field.
2 Add the source file(s) that call MAT API functions to the project.
1-17
1
MATLAB 5.1 Enhancements
3 On Power Macintoshes, add the shared libraries libmx and libmat from the
<MATLAB>extern:lib:PowerMac: folder to the project.
On 68K Macintoshes, add the static libraries libmx.lib, libmi.lib,
libut.lib, and libmat.lib from the
<MATLAB>:extern:lib:68k:Metrowerks: folder to the project.
You can now build and link your project as normally done in CodeWarrior.
1-18
Stateflow
Stateflow
Addition to the Simulink Modeling Environment
Stateflow is a major new product addition to the Simulink modeling and
simulation environment. A graphical tool for designing complex control and
supervisory logic systems, Stateflow allows you to model and simulate the
behavior of complex reactive, event-based systems based on finite state
machine theory. Stateflow lets you add event-driven elements of a system to
Simulink continuous or discrete modeling for a single, closed-loop simulation.
Stateflow represents an evolution from finite state machine theory by adding
several major improvements, including hierarchy, parallelism, junctions, and
history. These changes enable Stateflow to make practical use of finite state
machine theory with realistic application to control systems.
A major benefit of Stateflow is its seamless point-and-click interface to
Simulink. The control behavior that Stateflow models provides an ideal
complement to the algorithmic behavior modeled in Simulink. In Simulink, you
develop your model of continuous- and discrete-time dynamic systems using its
graphical, block diagram environment. Then you drag-and-drop the blocks that
represent Stateflow diagrams directly into your Simulink model to add
event-driven behavior to Simulink simulations.
Applications for Stateflow include developing the control logic in embedded
systems for electronic and mechanical systems found in automobiles, aircraft,
telecommunications systems, computer peripherals, office automation
equipment, and medical instrumentation.
Stateflow works with the latest versions of Simulink and Real-Time Workshop
— the automatic code generator for Simulink — to offer an integrated
environment for modeling, simulating, and prototyping real-time embedded
systems applications.
Stateflow Coder
Stateflow provides automatic C code generation through the optional Stateflow
Coder. C code generated by Stateflow Coder can be used independently or
integrated with code from Real-Time Workshop. Thus, Simulink, Stateflow,
and Real-Time Workshop are integrated from the design and modeling phase
through the code generation stage. The generated code can be executed for
rapid prototyping, hardware-in-the-loop testing or for stand-alone simulations.
1-19
1
MATLAB 5.1 Enhancements
Mapping Toolbox
The Mapping Toolbox is a MATLAB toolbox for geographic display and
cartographic analysis. The toolbox gives you the ability to plot geographically
based information as easily as any other type of data that you can plot in
MATLAB. Both vector and matrix map data can be displayed, manipulated,
and analyzed. The toolbox manages the projection, clipping, and trimming of
the data automatically for you, even if you change the projection.
The Mapping Toolbox provides more than 60 map projections. There are
extensive geographic analysis functions, such as computations of distance,
tracks, great and small circles, intersections, and navigation functions. These
computations can be made for a spherical body, or can make use of spheroidal
models of the earth and other planets when more accuracy is required. Utility
functions allow you to convert easily between different time, distance, and
angle units.
The toolbox provides a number of global map data sets, and allows you to
import more detailed data from government sources over the Internet and on
CD-ROM. These data sets include the Digital Chart of the World, Tiger/Line
files, and Digital Elevation Models of the world and the United States.
In addition to the command-line functions, the toolbox also provides an
extensive suite of graphical user interfaces (GUIs) for accessing the toolbox
functionality. These GUIs allow you to manage data interactively, plot it,
modify the display, make measurements, and generate geographic data like
tracks and circles. The GUIs are available as an integrated set and also are
available individually at any time.
1-20
2
MATLAB 5.0
Enhancements
Who Should Read This Chapter? . . . . . . . . . . . 2-2
MATLAB 5.0 Enhancements . . . . . . . . . . . . . 2-3
New Data Constructs . . . . . . . . . . . . . . . . 2-6
New and Enhanced Language Functions . . . . . . . 2-15
New Data Analysis Features . . . . . . . . . . . . . 2-21
New and Enhanced Handle Graphics Features
. . . . 2-24
New and Enhanced Handle Graphics Object Properties 2-35
Improvements to Graphical User Interfaces (GUIs)
. . 2-44
Enhanced Application Program Interface (API) . . . . 2-46
New Platform-Specific Features . . . . . . . . . . . 2-48
2
MATLAB 5.0 Enhancements
Who Should Read This Chapter?
Upgrading from MATLAB 5.0 to MATLAB 5.1?
If you are upgrading from MATLAB 5.0 to MATLAB 5.1, you should read
Chapter 1. You can skip this chapter, Chapter 2, because it documents features
that were already described in the MATLAB 5.0 documentation.
You should also read Chapter 3, which includes information about converting
MATLAB 5.0 applications to MATLAB 5.1.
Note: Chapter 3 expands upon conversion issues discussed in the MATLAB 5
New Features Guide; the additional information is highlighted with change
bars in the left margin.
Upgrading from MATLAB 4 to MATLAB 5.1?
If you are upgrading from MATLAB 4 to MATLAB 5.1, you should read
Chapter 1 as well as this whole chapter (Chapter 2). By reading both chapters,
you will get a complete picture of the new features in MATLAB 5.1 that have
been added since MATLAB 4.
You should also read Chapter 3, which includes information about converting
MATLAB 4 applications to MATLAB 5.1.
2-2
MATLAB 5.0 Enhancements
MATLAB 5.0 Enhancements
MATLAB 5.0 features five major areas of new functionality:
• Enhanced programming and application development tools
• New data types, structures, and language features
• Faster, better graphics and visualization
• More mathematical and data analysis tools
• Major enhancements to the MATLAB application toolbox suite and to
Simulink
Enhanced Programming and Application
Development Tools
MATLAB 5.0 provides new M-file programming enhancements and application
development tools that make it easier than ever to develop and maintain
applications in MATLAB. Highlights include:
• Integrated M-file editor
• Visual M-file debugger
• M-file performance profiler
• Search path browser/editor
• Workspace browser
• Web-based online Help Desk/documentation viewer
• GUI builder
• Handle Graphics property editor
• Preparsed P-code files (P-files)
• Enhanced, self-diagnosing Application Program Interface (API)
2-3
2
MATLAB 5.0 Enhancements
New Data Types, Structures, and Language
Features
MATLAB 5.0 introduces new data types and language improvements. These
new features make it easy to build much larger and more complex MATLAB
applications.
• Multidimensional arrays
• User-definable data structures
• Cell arrays: multitype data arrays
• Character arrays: two bytes per character
• Single byte data type for images
• Object-oriented programming
• Variable-length argument lists
• Multifunction and private M-files
• Function and operator overloading
• switch/case statements
Faster, Better Graphics and Visualization
MATLAB 5.0 adds powerful new visualization techniques and significantly
faster graphics using the Z-buffer algorithm. Presentation graphics are also
improved to give you more options and control over how you present your data.
• Visualization
- Truecolor (RGB) support
- Fast and accurate Z-buffer display algorithm
- Flat, Gouraud, and Phong lighting
- Vectorized patches for three dimensional modeling
- Camera view model, perspective
- Efficient 8-bit image display
- Image file import/export
2-4
MATLAB 5.0 Enhancements
• Presentation graphics
- Greek symbols, sub/superscripts, multiline text
- Dual axis plots
- Three-dimensional quiver, ribbon, and stem plots
- Pie charts, three-dimensional bar charts
- Extended curve marker symbol family
More Mathematical and Data Analysis Tools
With more than 500 mathematical, statistical, and engineering functions,
MATLAB gives you immediate access to the numeric computing tools you need.
New features with MATLAB 5.0 include:
• New ordinary differential equation solvers (ODEs)
• Delaunay triangulation
• Gridding for irregularly sampled data
• Set theory functions
• Two-dimensional quadrature
• Time and date handling functions
• Multidimensional interpolation, convolution, and FFT’s
• Bit-wise operators
• Iterative sparse methods
• Sparse matrix eigenvalues and singular values
Enhancements to Application Toolboxes
and to Simulink
Significant upgrades available introduced with MATLAB 5.0 are:
• Simulink 2.0
• Image Processing Toolbox 2.0
• Control System Toolbox 4.0
• Signal Processing Toolbox 4.0
• Optimization Toolbox 2.0
2-5
2
MATLAB 5.0 Enhancements
New Data Constructs
MATLAB 5.0 supports these new data constructs:
• Multidimensional arrays
• Cell arrays
• Structures
• Objects
In addition, MATLAB 5.0 features character arrays that incorporate an
improved storage method for string data.
Multidimensional Arrays
Arrays (other than sparse matrices) are no longer restricted to two dimensions.
You can create and access arrays with two or more dimensions by
• Using MATLAB functions like zeros, ones, or rand
• Using the new cat function
• Using the repmat function
• Indexing an existing array
MATLAB functions like zeros, ones, and rand have been extended to accept
more than two dimensions as arguments. To create a 3-by-4-by-5 array of ones,
for example, use
A = ones(3,4,5)
The new cat function enables you to concatenate arrays along a specified
dimension. For example, create two rectangular arrays A and B:
A = [1 2 3; 4 5 6];
B = [6 2 0; 9 1 3];
2-6
New Data Constructs
To concatenate these along the third dimension:
C = cat(3,A,B)
C(:,:,1) =
1
4
2
5
3
6
2
1
0
3
C(:,:,2) =
6
9
You can also create an array with two or more dimensions in which every
element has the same value using the repmat function. repmat accepts the
value with which to fill the array, followed by a vector of dimensions for the
array. For example, to create a 2-by-2-by-3-by-3 array B where every element
has the value pi:
B = repmat(pi,[2 2 3 3]);
You can also use repmat to replicate or “tile” arrays in a specified configuration.
Table 2-1: New Multidimensional Array Functions
Function
Description
cat
Concatenate arrays.
flipdim
Flip array along specified dimension.
ndgrid
Generate arrays for multidimensional functions
and interpolation.
ndims
Number of array dimensions.
permute, ipermute
Permute the dimensions of a multidimensional
array.
reshape
Change size.
shiftdim
Shift dimensions.
2-7
2
MATLAB 5.0 Enhancements
Table 2-1: New Multidimensional Array Functions (Continued)
Function
Description
squeeze
Remove singleton array dimensions.
sub2ind, ind2sub
Single index from subscripts; subscripts from linear
index.
Cell Arrays
Cell arrays have elements that are containers for any type of MATLAB data,
including other cells. You can build cell arrays using:
• The cell array constructor {}
• Assignment statements (for instance, A{2,2} = 'string')
• The new cell function
Table 2-2: New Cell Array Functions
Function
Description
cell
Create cell array.
cell2struct
Cell array to structure array conversion.
celldisp
Display top-level structure of cell array.
cellplot
Graphically display the structure of a cell array.
num2cell
Convert a matrix into a cell array.
Structures
Structures are constructs that have named fields containing any kind of data.
For example, one field might contain a text string representing a name
(patient.name = 'Jane Doe'), another might contain a scalar representing a
billing amount (patient.billing = 127.00), and a third might hold a matrix
of medical test results. You can organize these structures into arrays of data.
2-8
New Data Constructs
Create structure arrays by using individual assignment statements or the new
struct function.
Table 2-3: New Structure Functions
Function
Description
fieldnames
Field names of structure array.
getfield
Get field of structure array.
rmfield
Remove structure fields.
setfield
Set field of structure array.
struct
Create structure array.
struct2cell
Structure to cell array conversion.
MATLAB Objects
Object-oriented programming is now available within the MATLAB
environment.
Objects
The MATLAB programming language does not require the use of data types.
For many applications, however, it is helpful to associate specific attributes
with certain categories of data. To facilitate this, MATLAB allows you to work
with objects. Objects are typed structures. A single class name identifies both
the type of the structure and the name of the function that creates objects
belonging to that class.
Objects differ from ordinary structures in two important ways:
Data hiding. The structure fields of objects are not visible from the command
line. Instead, you can access structure fields only from within a method, an
M-file associated with the object class. Methods reside in class directories.
Class directories have the same name as the class, but with a prepended @
symbol. For example, a class directory named @inline might contain methods
for a class called inline.
2-9
2
MATLAB 5.0 Enhancements
Function and expression overloading. You can create methods that override
existing M-files. If an object calls a function, MATLAB first checks to see if
there is a method of that name before calling a supplied M-file of that name.
You can also provide methods that are called for MATLAB operators. For
objects a and b, for instance, the expression a + b calls the method plus(a,b)
if it exists.
Character Arrays
Strings now take up less memory than they did in previous releases.
MATLAB 4 required 64 bits per character for string data. MATLAB 5.0
requires only 16 bits per character.
Table 2-4: New Character String Functions
2-10
Function
Description
base2dec
Convert base B to decimal number.
bin2dec
Convert binary to decimal number.
char
Convert numeric values to string.
dec2base
Convert decimal number to base.
dec2bin
Convert decimal to binary number.
mat2str
Convert a matrix into a string.
strcat
String concatenation.
strmatch
Find possible matches for a string.
strncmp
Compare the first n characters of two strings.
strvcat
Vertical concatenation of strings.
New Data Constructs
Table 2-5: New Object-Oriented Functions
Function
Description
class
Create or return class of object.
isa
True if object is a given class.
inferiorto
Inferior class relationship.
superiorto
Superior class relationship.
Programming Capabilities
MATLAB 5.0 includes flow-control improvements and new M-file
programming tools.
Flow-Control Improvements
MATLAB 5.0 features:
• A new flow-control statement, the switch statement
• More efficient evaluation of if expressions
The switch statement is a convenient way to execute code conditionally when
you have many possible cases to choose from. It is no longer necessary to use a
series of elseif statements:
switch input_num
case –1
disp('negative one');
case 0
disp('zero');
case 1
disp('positive one');
otherwise
disp('other value');
end
Only the first matching case is executed.
2-11
2
MATLAB 5.0 Enhancements
switch can handle multiple conditions in a single case statement by enclosing
the case expression in a cell array. For example, assume method exists as a
string variable:
switch lower(method)
case {'linear','bilinear'}, disp('Method is linear')
case 'cubic', disp('Method is cubic')
case 'nearest', disp('Method is nearest')
otherwise, disp('Unknown method.')
end
Table 2-6: New Flow Control Commands
Command
Description
case
Case switch.
otherwise
Default part of switch statement.
switch
Conditionally execute code, switching among
several cases.
MATLAB now evaluates if expressions more efficiently than before. For
example, consider the expression if a|b. If a is true, then MATLAB will not
evaluate b. Similarly, MATLAB won’t execute statements following the
expression if a&b in the event a is found to be false.
Table 2-7: New Logical Operators
2-12
Operator
Description
iscell
True for a cell array.
isequal
True if arrays are equal.
isfinite
True for finite elements.
islogical
True for logical arrays.
isnumeric
True if input is a numeric array.
isstruct
True for a structure.
logical
Convert numeric values to logical vectors.
New Data Constructs
M-File Programming Tools
MATLAB 5.0 adds three features to enhance MATLAB’s M-file programming
capabilities.
Variable Number of Input and Output Arguments
The varargin and varargout commands simplify the task of passing data into
and out of M-file functions. For instance, the statement function varargout
= myfun(A,B) allows M-file myfun to return an arbitrary number of output
arguments, while the statement function [C,D] = myfun(varargin) allows
it to accept an arbitrary number of input arguments.
Multiple Functions Within an M-File
It is now possible to have subfunctions within the body of an M-file. These are
functions that the primary function in the file can access but that are otherwise
invisible.
M-File Profiler
This utility lets you debug and optimize M-files by tracking cumulative
execution time for each line of code. Whenever the specified M-file executes, the
profiler counts how many time intervals each line uses.
Pseudocode M-Files
The pcode command saves a pseudocode version of a function or script to disk
for later sessions. This pseudocode version is ready-to-use code that MATLAB
can access whenever you invoke the function.
Table 2-8: New Programming Tools
Function
Description
addpath
Append directory to MATLAB’s search path.
assignin
Assign variable in workspace.
edit
Edit an M-file.
editpath
Modify current search path.
evalin
Evaluate variable in workspace.
2-13
2
MATLAB 5.0 Enhancements
Table 2-8: New Programming Tools (Continued)
2-14
Function
Description
fullfile
Build full filename from parts.
inmem
Functions in memory.
inputname
Input argument name.
mfilename
Name of the currently running M-file.
mexext
Return the MEX filename extension.
pcode
Create pseudocode file (P-file).
profile
Measure and display M-file execution profiles.
rmpath
Remove directories from MATLAB’s search path.
varargin,
varargout
Pass or return variable numbers of arguments.
warning
Display warning message.
web
Point Web browser at file or Web site.
New and Enhanced Language Functions
New and Enhanced Language Functions
MATLAB 5.0 provides a large number of new language functions as well as
enhancements to existing functions.
Table 2-9: New Elementary and Specialized Math Functions
Function
Description
airy
Airy functions.
besselh
Bessel functions of the third kind (Hankel).
condeig
Condition number with respect to eigenvalues.
condest
1-norm matrix condition estimate.
dblquad
Numerical double integration
mod
Modulus (signed remainder after division).
normest
2-norm estimate.
Table 2-10: New Time and Date Functions
Function
Description
calendar
Calendar.
datenum
Serial date number.
datestr
Create date string.
datetick
Date formatted tick labels.
datevec
Date components.
eomday
End of month.
now
Current date and time.
weekday
Day of the week.
2-15
2
MATLAB 5.0 Enhancements
Table 2-11: New Ordinary Differential Equation Functions
Function
Description
ode45, ode23, ode113,
ode23s, ode15s
Solve differential equations, low- and highorder methods.
odefile
Define a differential equation problem for
ODE solvers.
odeget
Extract options from an argument created
with odeset.
odeset
Create and edit input arguments for ODE
solvers.
Table 2-12: New Matrix Functions
Function
Description
cholinc
Incomplete Cholesky factorization.
gallery
More than 50 new test matrices.
luinc
Incomplete LU factorization.
repmat
Replicate and tile an array.
sprand
Random uniformly distributed sparse matrices.
Table 2-13: New Methods for Sparse Matrices
2-16
Method
Description
bicg
BiConjugate Gradients method.
bicgstab
BiConjugate Gradients Stabilized method.
cgs
Conjugate Gradients Squared method.
eigs
Find a few eigenvalues and eigenvectors.
gmres
Generalized Minimum Residual method.
New and Enhanced Language Functions
Table 2-13: New Methods for Sparse Matrices (Continued)
Method
Description
pcg
Preconditioned Conjugate Gradients method.
qmr
Quasi-Minimal Residual method.
svds
A few singular values.
Subscripting and Assignment Enhancements
In MATLAB 5.0, you can now:
• Access the last element of an array using the end keyword.
• Obtain consistent results for indexing expressions consisting of all ones.
• Use scalar expansion in subarray assignments.
A statement like A(ones([m,n])) now always returns an m-by-n array in which
each element is A(1). In previous versions, the statement returned different
results depending on whether A was or was not an m-by-n matrix.
In previous releases, expressions like A(2:3,4:5) = 5 resulted in an error.
MATLAB 5.0 automatically “expands” the 5 to be the right size (that is,
5∗ones(2,2)).
Integer Bit Manipulation Functions
The ops directory contains commands that permit bit-level operations on
integers. Operations include setting and unsetting, complementing, shifting,
and logical AND, OR, and XOR.
Table 2-14: New Bitwise Functions
Function
Description
bitand
Bitwise AND.
bitcmp
Complement bits.
bitget
Get bit.
bitmax
Maximum floating-point integer.
2-17
2
MATLAB 5.0 Enhancements
Table 2-14: New Bitwise Functions (Continued)
Function
Description
bitor
Bitwise OR.
bitset
Set bit.
bitshift
Bitwise shift.
bitxor
Bitwise XOR.
Dimension Specification for Data Analysis Functions
MATLAB’s basic data analysis functions now enable you to supply a second
input argument. This argument specifies the dimension along which the
function operates. For example, create an array A:
A = [3 2 4; 1 0 5; 8 2 6];
To sum along the first dimension of A, incrementing the row index, specify 1 for
the dimension of operation:
sum(A,1)
ans =
12
4
15
To sum along the second dimension, incrementing the column index, specify 2
for the dimension:
sum(A,2)
ans =
9
6
16
Other functions that accept the dimension specifier include prod, cumprod, and
cumsum.
2-18
New and Enhanced Language Functions
Wildcards in Utility Commands
The asterisk (*) can be used as a wildcard in the clear and whos commands.
This allows you, for example, to clear only variables beginning with a given
character or characters, as in
clear A*
Empty Arrays
Earlier versions of MATLAB allowed for only one empty matrix, the 0-by-0
matrix denoted by []. MATLAB 5.0 provides for matrices and arrays in which
some, but not all, of the dimensions are zero. For example, 1-by-0,
10-by-0-by-20, and [3 4 0 5 2] are all possible array sizes.
The two-character sequence [] continues to denote the 0-by-0 matrix. Empty
arrays of other sizes can be created with the functions zeros, ones, rand, or
eye. To create a 0-by-5 matrix, for example, use
E = zeros(0,5)
The basic model for empty matrices is that any operation that is defined for
m-by-n matrices, and that produces a result with a dimension that is some
function of m and n, should still be allowed when m or n is zero. The size of the
result should be that same function, evaluated at zero.
For example, horizontal concatenation
C = [A B]
requires that A and B have the same number of rows. So if A is m-by-n and B is
m-by-p, then C is m-by-(n+p). This is still true if m or n or p is zero.
Many operations in MATLAB produce row vectors or column vectors. It is now
possible for the result to be the empty row vector
r = zeros(1,0)
or the empty column vector
c = zeros(0,1)
Some MATLAB functions, like sum and max, are reductions. For matrix
arguments, these functions produce vector results; for vector arguments they
produce scalar results. Backwards compatibility issues arise for the argument
[], which in MATLAB 4 played the role of both the empty matrix and the
2-19
2
MATLAB 5.0 Enhancements
empty vector. In MATLAB 5.0, empty inputs with these functions produce
these results:
• sum([]) is 0
• prod([]) is 1
• max([]) is []
• min([]) is []
2-20
New Data Analysis Features
New Data Analysis Features
MATLAB 5.0 provides an expanded set of basic data analysis functions.
Table 2-15: New Statistical Data Analysis Functions
Function
Description
convhull
Convex hull.
cumtrapz
Cumulative trapezoidal numerical integration.
delaunay
Delaunay triangularization.
dsearch
Search for nearest point.
factor
Prime factors.
inpolygon
Detect points inside a polygonal region.
isprime
True for prime numbers.
nchoosek
All possible combinations of n elements taken k at a
time.
perms
All possible permutations.
polyarea
Area of polygon.
primes
Generate a list of prime numbers.
sortrows
Sort rows in ascending order.
tsearch
Search for enclosing Delaunay triangle.
voronoi
Voronoi diagram.
MATLAB 5.0 also offers expanded data analysis in the areas of:
• Higher-dimension interpolation
• Extended griddata functionality based on Delaunay triangulation
• New set theoretic functions
2-21
2
MATLAB 5.0 Enhancements
Higher-Dimension Interpolation
The new functions interp3 and interpn let you perform three-dimensional
and multidimensional interpolation. ndgrid provides arrays that can be used
in multidimensional interpolation.
Table 2-16: New Interpolation Functions
Function
Description
interp3
Three-dimensional data interpolation (table
lookup).
interpn
Multidimensional data interpolation (table lookup).
ndgrid
Generate arrays for multidimensional functions
and interpolation.
griddata Based on Delaunay Triangulation
griddata supports triangle-based interpolation using nearest neighbor, linear,
and cubic techniques. It creates smoother contours on scattered data using the
cubic interpolation method.
Set Theoretic Functions
The functions union, intersect, ismember, setdiff, and unique treat vectors
as sets, allowing you to perform operations like union A ∪ B , intersection
A ∩ B , and difference A – B of such sets. Other set-theoretical operations
include location of common set elements (ismember) and elimination of
duplicate elements (unique).
Table 2-17: New Set Functions
2-22
Function
Description
intersect
Set intersection of two vectors.
ismember
Detect members of a set.
setdiff
Return the set difference of two vectors.
setxor
Set XOR of two vectors.
New Data Analysis Features
Table 2-17: New Set Functions (Continued)
Function
Description
union
Set union of two vectors.
unique
Unique elements of a vector.
2-23
2
MATLAB 5.0 Enhancements
New and Enhanced Handle Graphics Features
MATLAB 5.0 features significant improvements to Handle Graphics. For
details on all graphics functions, see Using MATLAB Graphics.
Plotting Capabilities
MATLAB’s basic plotting capabilities have been improved and expanded in
MATLAB 5.0.
Table 2-18: New and Enhanced Plotting Capabilities
Function
Description
area
Filled area plot.
bar3
Vertical 3-D bar chart.
bar3h
Horizontal 3-D bar chart.
barh
Horizontal bar chart.
pie
Pie chart.
pie3
Three-dimensional pie chart.
plotyy
Plot graphs with Y tick labels on left and right.
Filling Areas
The area function plots a set of curves and fills the area beneath the curves.
Bar Chart Enhancements
bar3, bar3h, and barh draw vertical and horizontal bar charts. These functions,
together with bar, support multiple filled bars in grouped and stacked formats.
2-24
New and Enhanced Handle Graphics Features
Labels for Patches and Surfaces
legend can label any solid-color patch and surface. You can now place legends
on line, bar, ribbon, and pie plots, for example.
Table 2-19: New Graph Annotation Functions
Function
Description
box
Axes box.
datetick
Display dates for Axes tick labels.
Marker Style Enhancement
A number of new line markers are available, including, among others, a
square, a diamond, and a five-pointed star. These can be specified
independently from line style.
Stem Plot Enhancements
stem and stem3 plot discrete sequence data as filled or unfilled stem plots.
Three-Dimensional Plotting Support
quiver3 displays three-dimensional velocity vectors with (u,v,w) components.
The ribbon function displays data as three-dimensional strips.
Table 2-20: New Three-Dimensional Plotting Functions
Function
Description
quiver3
Three-dimensional quiver plot.
ribbon
Draw lines as 3-D strips.
stem3
Three-dimensional stem plot.
Data Visualization
MATLAB 5.0 features many new and enhanced capabilities for data
visualization.
2-25
2
MATLAB 5.0 Enhancements
New Viewing Model
Axes camera properties control the orthographic and perspective view of the
scene created by an Axes and its child objects. You can view the Axes from any
location around or in the scene, as well as adjust the rotation, view angle, and
target point.
New Method for Defining Patches
You can define a Patch using a matrix of faces and a matrix of vertices. Each
row of the face matrix contains indices into the vertex matrix that define the
connectivity of the face. Defining Patches in this way reduces memory
consumption because you no longer need to specify redundant vertices.
Triangular Meshes and Surfaces
The new functions trimesh and trisurf create triangular meshes and surfaces
from x, y, and z vector data and a list of indices into the vector data.
Table 2-21: New Triangular Mesh and Surface Functions
Function
Description
trisurf
Triangular surface plot.
trimesh
Triangular mesh plot.
Improved Slicing
slice now supports an arbitrary slicing surface.
Contouring Enhancements
The contouring algorithm now supports parametric surfaces and contouring on
triangular meshes. In addition, clabel rotates and inserts labels in contour
plots.
Table 2-22: New Contour Plot
2-26
Function
Description
contourf
Filled contour plot.
New and Enhanced Handle Graphics Features
New zoom Options
The zoom function supports two new options:
• scale_factor – zooms by the specified scale factor relative to the current
zoom state (e.g., zoom(2) zooms in by a factor of two).
• fill – zooms to the point where the objects contained in the Axes are as large
as they can be without extending beyond the Axes plot box from any view.
Use this option when you want to rotate the Axes without seeing an apparent
size change.
Graphics Presentation
MATLAB 5.0 provides improved control over the display of graphics objects.
Enhancements to Axes Objects
MATLAB 5.0 provides more advanced control for three-dimensional Axes
objects. You can control the three-dimensional aspect ratio for the Axes’ plot
box, as well as for the data displayed in the plot box. You can also zoom in and
out from a three-dimensional Axes using viewport scaling and Axes camera
properties.
The axis command supports a new option designed for viewing graphics
objects in 3-D:
axis vis3d
This option prevents MATLAB from stretching the Axes to fit the size of the
Figure window and otherwise altering the proportions of the objects as you
change the view.
In a two-dimensional view, you can display the x-axis at the top of an Axes and
the y-axis at the right side of an Axes.
Color Enhancements
colordef white or colordef black changes the color defaults on the root so
that subsequent figures produce plots with a white or black axes background
color. The figure background color is changed to be a shade of gray, and many
other defaults are changed so that there will be adequate contrast for most
2-27
2
MATLAB 5.0 Enhancements
plots. colordef none sets the defaults to their MATLAB 4 values. In addition,
a number of new colormaps are available.
Table 2-23: New Figure and Axis Color Control
Function
Description
colordef
Select Figure color scheme.
Table 2-24: New Colormaps
Function
Description
autumn
Shades of red and yellow colormap.
colorcube
Regularly spaced colors in RGB colorspace, plus
more steps of gray, pure red, pure green, and pure
blue.
lines
Colormap of colors specified by the Axes’
ColorOrder property.
spring
Shades of magenta and yellow colormap.
summer
Shades of green and yellow colormap.
winter
Shades of blue and green colormap.
Text Object Enhancements
MATLAB 5.0 supports a subset of TeX commands. A single Text graphics object
can support multiple fonts, subscripts, superscripts, and Greek symbols. See
the text function in the online MATLAB Function Reference for information
about the supported TeX subset.
You can also specify multiline character strings and use normalized font units
so that Text size is a fraction of an Axes’ or Uicontrol’s height. MATLAB
supports multiline text strings using cell arrays. Simply define a string
variable as a cell array with one line per cell.
2-28
New and Enhanced Handle Graphics Features
Improved General Graphics Features
The MATLAB startup file sets default properties for various graphics objects
so that new Figures are aesthetically pleasing and graphs are easier to
understand.
Table 2-25: New Figure Window Creation and Control Command
Command
Description
dialog
Create a dialog box.
Z-buffering is now available for fast and accurate three-dimensional rendering.
MATLAB 5.0 provides built-in menus on X Windows. Figure MenuBar
'figure' is now supported on UNIX.
Lighting
MATLAB supports a new graphics object called a Light. You create a Light
object using the light function. Three important Light object properties are:
• Color – the color of the light cast by the Light object
• Style – either infinitely far away (the default) or local
• Position – the direction (for infinite light sources) or the location (for local
light sources)
You cannot see Light objects themselves, but you can see their effect on any
Patch and Surface objects present in the same Axes. You can control these
effects by setting various Patch and Surface object properties.
AmbientStrength, DiffuseStrength, and SpecularStrength control the
intensity of the respective light-reflection characteristics;
SpecularColorReflectance and SpecularExponent provide additional control
over the reflection characteristics of specular light.
The Axes AmbientLightColor property determines the color of the ambient
light, which has no direction and affects all objects uniformly. Ambient light
effects occur only when there is a visible Light object in the Axes.
The Light object’s Color property determines the color of the directional light,
and its Style property determines whether the light source is a point source
(Style set to local), which radiates from the specified position in all directions,
2-29
2
MATLAB 5.0 Enhancements
or a light source placed at infinity (Style set to infinite), which shines from
the direction of the specified position with parallel rays.
You can also select the algorithm used to calculate the coloring of the lit objects.
The Patch and Surface EdgeLighting and FaceLighting properties select
between no lighting, and flat, Gouraud, or Phong lighting algorithms.
print Command Revisions
The print command has been extensively revised for MATLAB 5.0. Consult
Using MATLAB Graphics for a complete description of print command
capabilities. Among the new options available for MATLAB 5.0:
• The –loose option makes the PostScript bounding box equal to the Figure’s
PaperPosition property. PICT (Macintosh) and EPSI (X Windows) previews
are the same size as the generated PostScript drawing.
• Z-buffer images may be printed at user-selectable resolution.
• The –dmeta option now supports Enhanced Windows Metafiles.
• print –dmfile generates an M-file that recreates a Figure.
• Uicontrol objects print by default unless suppressed with the –noui option.
In earlier versions of MATLAB, uicontrols did not appear when you printed
Figures. If you specify the –noui option with the print command, MATLAB
ignores uicontrols and prints only Axes and Axes children.
Additional print Device Options
The print command has several new device options:
Table 2-26: print Command Device Options
2-30
Device
Description
–dljet4
HP LaserJet 4 (defaults to 600 dpi)
–ddeskjet
HP DeskJet and DeskJet Plus
–ddjet500
HP Deskjet 500
–dcdj500
HP DeskJet 500C
–dcdj550
HP Deskjet 550C
New and Enhanced Handle Graphics Features
Table 2-26: print Command Device Options (Continued)
Device
Description
–dpjxl
HP PaintJet XL color printer
–dpjxl300
HP PaintJet XL300 color printer
–ddnj650c
HP DesignJet 650C
–dbj200
Canon BubbleJet BJ200
–dbjc600
Canon Color BubbleJet BJC-600 and BJC-4000
–dibmpro
IBM 9-pin Proprinter
–dbmp256
8-bit (256-color) BMP file format
–dbmp16m
24-bit BMP file format
–dpcxmono
Monochrome PCX file format
–dpcx24b
24-bit color PCX file format, three 8-bit planes
–dpbm
Portable Bitmap (plain format)
–dpbmraw
Portable Bitmap (raw format)
–dpgm
Portable Graymap (plain format)
–dpgmraw
Portable Graymap (raw format)
–dppm
Portable Pixmap (plain format)
–dppmraw
Portable Pixmap (raw format)
Image Support
MATLAB 5.0 provides a number of enhancements to image support. These
enhancements include:
• Truecolor support
• New functions for reading images from and writing images to graphics files
• 8-bit image support
2-31
2
MATLAB 5.0 Enhancements
Truecolor
In addition to indexed images, in which colors are stored as an array of indices
into a colormap, MATLAB 5.0 now supports truecolor images. A truecolor
image does not use a colormap; instead, the color values for each pixel are
stored directly as RGB triplets. In MATLAB, the CData property of a truecolor
Image object is a three-dimensional (m-by-n-by-3) array. This array consists of
three m-by-n matrices (representing the red, green, and blue color planes)
concatenated along the third dimension.
Reading and Writing Images
The imread function reads image data into MATLAB arrays from graphics files
in various standard formats, such as TIFF. You can then display these arrays
using the image function, which creates a Handle Graphics Image object. You
can also write MATLAB image data to graphics files using the imwrite
function. imread and imwrite both support a variety of graphics file formats
and compression schemes.
8-Bit Images
When you read an image into MATLAB using imread, the data is stored as an
array of 8-bit integers. This is a much more efficient storage method than the
double-precision (64-bit) floating-point numbers that MATLAB typically uses.
The Handle Graphics Image object has been enhanced to support 8-bit CData.
This means you can display 8-bit images without having to convert the data to
double precision. MATLAB 5.0 also supports a limited set of operations on
these 8-bit arrays. You can view the data, reference values, and reshape the
array in various ways. To perform any mathematical computations, however,
you must first convert the data to double precision, using the double function.
Note that, in order to support 8-bit images, certain changes have been made in
the way MATLAB interprets image data. This table summarizes the
conventions MATLAB uses:
2-32
New and Enhanced Handle Graphics Features
Image
Type
Double-Precision Data
(Double Array)
Indexed
(colormap)
Image is stored as a 2-D (m-by-n) array
of integers in the range
[1,length(colormap)]; colormap is an
m-by-3 array of floating-point values in
the range [0, 1]
Image is stored as a 2-D (m-by-n) array
of integers in the range [0, 255];
colormap is an m-by-3 array of
floating-point values in the range [0, 1]
Truecolor
(RGB)
Image is stored as a 3-D (m-by-n-by-3)
array of floating-point values in the
range [0, 1]
Image is stored as a 3-D (m-by-n-by-3)
array of integers in the range [0, 255]
8-Bit Data (uint8 Array)
Note that MATLAB interprets image data very differently depending on
whether it is double precision or 8-bit. The rest of this section discusses things
you should keep in mind when working with image data to avoid potential
pitfalls. This information is especially important if you want to convert image
data from one format to another.
Indexed images
In an indexed image of class double, the value 1 points to the first row in the
colormap, the value 2 points to the second row, and so on. In a uint8 indexed
image, there is an offset; the value 0 points to the first row in the colormap, the
value 1 points to the second row, and so on. The uint8 convention is also used
in graphics file formats, and enables 8-bit indexed images to support up to 256
colors. Note that when you read in an indexed image with imread, the resulting
image array is always of class uint8. (The colormap, however, is of class
double; see below.)
If you want to convert a uint8 indexed image to double, you need to add 1 to
the result. For example:
X64 = double(X8) + 1;
To convert from double to uint8, you need to first subtract 1, and then use
round to ensure all the values are integers:
X8 = uint8(round(X64 – 1));
The order of the operations must be as shown in these examples, because you
cannot perform mathematical operations on uint8 arrays.
2-33
2
MATLAB 5.0 Enhancements
When you write an indexed image using imwrite, MATLAB automatically
converts the values if necessary.
Colormaps
Colormaps in MATLAB are always m-by-3 arrays of double-precision
floating-point numbers in the range [0, 1]. In most graphics file formats,
colormaps are stored as integers, but MATLAB does not support colormaps
with integer values. imread and imwrite automatically convert colormap
values when reading and writing files.
Truecolor Images
In a truecolor image of class double, the data values are floating-point
numbers in the range [0, 1]. In a truecolor image of class uint8, the data values
are integers in the range [0, 255].
If you want to convert a truecolor image from one data type to the other, you
must rescale the data. For example, this call converts a uint8 truecolor image
to double:
RGB64 = double(RGB8)/255;
This call converts a double truecolor image to uint8:
RGB8 = uint8(round(RGB*255));
The order of the operations must be as shown in these examples, because you
cannot perform mathematical operations on uint8 arrays.
When you write a truecolor image using imwrite, MATLAB automatically
converts the values if necessary.
2-34
New and Enhanced Handle Graphics Object Properties
New and Enhanced Handle Graphics Object Properties
This section lists new graphics object properties supported in MATLAB 5.0. It
also lists graphics properties whose behavior has changed significantly.
Using MATLAB Graphics provides a more detailed description of each
property.
Table 2-27: Properties of All Graphics Objects
Property
Description
BusyAction
Controls events that potentially interrupt
executing callback routines.
Children
Enhanced behavior allows reordering of child
objects.
CreateFcn
A callback routine that executes when
MATLAB creates a new instance of the
specific type of graphics object.
DeleteFcn
A callback routine that executes when
MATLAB deletes the graphics object.
HandleVisibility
Controls scope of handle visibility.
Interruptible
Now on by default.
Parent
Enhanced behavior allows reparenting of
graphics objects.
Selected
Indicates whether graphics object is in
selected state.
SelectionHighlight
Determines if graphics objects provide visual
indication of selected state.
Tag
User-specified object label.
2-35
2
MATLAB 5.0 Enhancements
Table 2-28: Axes Properties
2-36
Property
Description
AmbientLightColor
Color of the surrounding light illuminating
all Axes child objects when a Light object is
present.
CameraPosition
Location of the point from which the Axes is
viewed.
CameraPositionMode
Automatic or manual camera positioning.
CameraTarget
Point in Axes viewed from camera position.
CameraTargetMode
Automatic or manual camera target selection.
CameraUpVector
Determines camera rotation around the
viewing axis.
CameraUpVectorMode
Default or user-specified camera orientation.
CameraViewAngle
Angle determining the camera field of view.
CameraViewAngleMode
Automatic or manual camera field of view
selection.
DataAspectRatio
Relative scaling of x-, y-, and z-axis data
units.
DataAspectRatioMode
Automatic or manual axis data scaling.
FontUnits
Units used to interpret the FontSize property
(allowing normalized text size).
Layer
Draw axis lines below or above child objects.
NextPlot
Enhanced behavior supports add, replace,
and replacechildren options.
PlotBoxAspectRatio
Relative scaling of Axes plot box.
New and Enhanced Handle Graphics Object Properties
Table 2-28: Axes Properties (Continued)
Property
Description
PlotBoxAspectRatioMode
Automatic or manual selection of plot box
scaling.
Projection
Select orthographic or perspective projection
type.
TickDirMode
Automatic or manual selection of tick mark
direction (allowing you to change view and
preserve the specified TickDir).
XAxisLocation
Locate x-axis at bottom or top of plot.
YAxisLocation
Locate y-axis at left or right side of plot.
Table 2-29: Figure Properties
Property
Description
CloseRequestFcn
Callback routine executed when you issue a
close command on a Figure.
Dithermap
Colormap used for truecolor data on
pseudocolor displays.
DithermapMode
Automatic dithermap generation.
IntegerHandle
Integer or floating-point Figure handle.
PaperPositionMode
WYSIWYG printing of Figure.
NextPlot
Enhanced behavior supports add, replace,
and replacechildren options.
PointerShapeCData
User-defined pointer data.
PointerShapeHotSpot
Active point in custom pointer.
Renderer
Select painters or Z-buffer rendering.
2-37
2
MATLAB 5.0 Enhancements
Table 2-29: Figure Properties (Continued)
Property
Description
RendererMode
Enable MATLAB to select best renderer
automatically.
Resize
Determines if Figure window is resizeable.
ResizeFcn
Callback routine executed when you resize
the Figure window.
Table 2-30: Image Properties
Property
Description
CData
Enhanced behavior allows truecolor (RGB
values) specification.
CDataMapping
Select direct or scaled interpretation of
indexed colors.
EraseMode
Control drawing and erasing of Image objects.
Table 2-31: Light Properties
2-38
Property
Description
Color
Color of the light source.
Position
Place the light source within Axes space.
Style
Select infinite or local light source.
New and Enhanced Handle Graphics Object Properties
Table 2-32: Line Properties
Property
Description
Marker
The marker symbol to use at data points
(markers are now separate from line style).
MarkerEdgeColor
The color of the edge of the marker symbol.
MarkerFaceColor
The color of the face of filled markers.
Table 2-33: Patch Properties
Property
Description
AmbientStrength
The strength of the Axes ambient light on
the particular Patch object.
CData
Enhanced behavior allows truecolor (RGB
values) specification.
CDataMapping
Select direct or scaled interpretation of
indexed colors.
DiffuseStrength
Strength of the reflection of diffuse light
from Light objects.
FaceLightingAlgorithm
Lighting algorithm used for Patch faces.
Faces
The vertices connected to define each face.
FaceVertexCData
Color specification when using the Faces
and Vertices properties to define a Patch.
LineStyle
Type of line used for edges.
Marker
Symbol used at vertices.
MarkerEdgeColor
The color of the edge of the marker symbol.
MarkerFaceColor
The color of the face of filled markers.
MarkerSize
Size of the marker.
2-39
2
MATLAB 5.0 Enhancements
Table 2-33: Patch Properties (Continued)
Property
Description
NormalMode
MATLAB generated or user-specified
normal vectors.
SpecularColorReflectance
Control the color of the specularly reflected
light from Light objects.
SpecularExponent
Control the shininess of the Patch object.
SpecularStrength
Strength of the reflection of specular light
from Light objects.
VertexNormals
Definition of the Patch’s normal vectors.
Vertices
The coordinates of the vertices defining the
Patch.
Table 2-34: Root Properties
2-40
Property
Description
CallbackObject
Handle of object whose callback is currently
executing.
ErrorMessage
Text of the last error message issued by
MATLAB.
ErrorType
The type of the error that last occurred.
ShowHiddenHandles
Show or hide graphics object handles that
are marked as hidden.
TerminalHideGraphCommand
Command to hide graphics window when
switching to command mode.
TerminalDimensions
Size of graphics terminal.
New and Enhanced Handle Graphics Object Properties
Table 2-34: Root Properties
Property
Description
TerminalShowGraphCommand
Command to expose graphics window when
switching from command mode to graphics
mode.
Table 2-35: Surface Properties
Property
Description
AmbientStrength
The strength of the Axes ambient light on
the particular Surface object.
CData
Enhanced behavior allows truecolor (RGB
values) specification.
CDataMapping
Selects direct or scaled interpretation of
indexed colors.
DiffuseStrength
Strength of the reflection of diffuse light
from Light objects.
FaceLightingAlgorithm
Lighting algorithm used for Surface faces.
Marker
Symbol used at vertices.
MarkerEdgeColor
The color of the edge of the marker symbol.
MarkerFaceColor
The color of the face of filled markers.
MarkerSize
Size of the marker.
NormalMode
MATLAB generated or user-specified
normal vectors.
SpecularColorReflectance
Control the color of the specularly reflected
light from Light objects.
SpecularExponent
Control the shininess of the Surface object.
2-41
2
MATLAB 5.0 Enhancements
Table 2-35: Surface Properties (Continued)
Property
Description
SpecularStrength
Strength of the reflection of specular light
from Light objects.
VertexNormals
Definition of the Surface’s normal vectors.
Vertices
The coordinates of the vertices defining the
Surface.
Table 2-36: Text Properties
Property
Description
FontUnits
Select the units used to interpret the
FontSize property (allowing normalized text
size).
Interpreter
Allows MATLAB to interpret certain
characters as TeX commands.
Table 2-37: Uicontrol Properties
2-42
Property
Description
Enable
Enable or disable (gray out) uicontrols.
FontAngle
Select character slant.
FontName
Select font family.
FontSize
Select font size.
FontUnits
Select the units used to interpret the
FontSize property (allowing normalized text
size).
FontWeight
Select the weight of text characters.
New and Enhanced Handle Graphics Object Properties
Table 2-37: Uicontrol Properties (Continued)
Property
Description
ListboxTop
Select the listbox item to display at the top of
the listbox.
SliderStep
Select the size of the slider step.
Style
Enhanced to include listbox device.
Table 2-38: Uimenu Properties
Property
Description
Enable
Enable or disable (gray out) uicontrols.
2-43
2
MATLAB 5.0 Enhancements
Improvements to Graphical User Interfaces (GUIs)
General GUI Enhancements
MATLAB 5.0 provides general enhancements that are useful in the GUI area:
• Starting MATLAB with the –nosplash argument suppresses the splash
screen on UNIX.
• Using the CloseRequestFcn callback can abort a Figure close command.
• Stacking of Figure and Axes graphics objects can be varied to affect the order
in which MATLAB displays these objects.
• The mouse pointer can be set to a number of different symbols or you can
create a custom Figure pointer.
• On the Windows platforms, edit controls now have a three-dimensional
appearance.
MATLAB 5.0 provides features that make it easier to create MATLAB GUIs.
Major enhancements include List Box objects to display and select one or more
list items. You can also create modal or non-modal error, help, and warning
message boxes. In addition, uicontrol edit boxes now support multiline text.
Table 2-39: New GUI Functions
2-44
Function
Description
msgbox
Display message box.
dragrect
Drag pre-defined rectangles.
inputdlg
Display a dialog box to input data.
questdlg
Question dialog.
rbbox
Rubberband box.
selectmoveresize
Interactively select, move, or resize objects.
Improvements to Graphical User Interfaces (GUIs)
MATLAB 5.0 also provides more flexibility in callback routines. You can
specify callbacks that execute after creating, changing, and deleting an object.
Table 2-40: New Program Execution Functions
Function
Description
uiresume
Resume suspended M-file execution.
uiwait
Blocks program execution.
waitfor
Blocks execution until a condition is satisfied.
Guide
Guide is a Graphical User Interface (GUI) design tool. The individual pieces of
the Guide environment are designed to work together, but they can also be
used individually. For example, there is a Property Editor (invoked by the
command propedit) that allows you to modify any property of any Handle
Graphics object, from a figure to a line. Point the Property Editor at a line and
you can change its color, position, thickness, or any other line property.
The Control Panel is the centerpiece of the Guide suite of tools. It lets you
“control” a figure so that it can be easily modified by clicking and dragging. As
an example, you might want to move a button from one part of a figure to
another. From the Control Panel you put the button’s figure into an editable
state, and then it’s simply a matter of dragging the button into the new
position. Once a figure is editable, you can also add new uicontrols, uimenus,
and plotting axes.
Table 2-41: Guide Tools
Tool
Command
Description
Control Panel
guide
Control figure editing.
Property Editor
propedit
Modify object properties.
Callback Editor
cbedit
Modify object callbacks.
Alignment Tool
align
Align objects.
Menu Editor
menuedit
Modify figure menus.
2-45
2
MATLAB 5.0 Enhancements
Enhanced Application Program Interface (API)
The MATLAB 5.0 API introduces data types and functions not present in
MATLAB 4. This section summarizes the important changes in the API. For
details on any of these topics, see the MATLAB Application Program Interface
Guide.
New Fundamental Data Type
The MATLAB 4 Matrix data type is obsolete. MATLAB 5.0 programs use the
mxArray data type in place of Matrix. The mxArray data type has extra fields to
handle the richer data constructs of MATLAB 5.0.
Functions that expected Matrix arguments in MATLAB 4 expect mxArray
arguments in MATLAB 5.0.
New Functions
The API introduces many new functions that work with the C language to
support MATLAB 5.0 features.
Support for Structures and Cells
MATLAB 5.0 introduces structure arrays and cell arrays. Therefore, the
MATLAB 5.0 API introduces a broad range of functions to create structures
and cells, as well as functions to populate and analyze them. See “Recoding for
MATLAB 5.1 Compliance” on page 3-27 for a complete listing of these
functions.
Support for Multidimensional Arrays
The MATLAB 4 Matrix data type assumed that all matrices were
two-dimensional. The MATLAB 5.0 mxArray data type supports arrays of two
or more dimensions. The MATLAB 5.0 API provides two different mxCreate
functions that create either a two-dimensional or a multidimensional mxArray.
In addition, MATLAB 5.0 introduces several functions to get and set the
number and length of each dimension in a multidimensional mxArray.
Support for Nondouble Precision Data
The MATLAB 4 Matrix data type represented all numerical data as
double-precision floating-point numbers. The MATLAB 5.0 mxArray data type
2-46
Enhanced Application Program Interface (API)
can store numerical data in six different integer formats and two different
floating-point formats.
Note: Although the MATLAB API supports these different data
representations, MATLAB itself does not currently provide any operations or
functions that work with nondouble-precision data. Nondouble precision-data
may be viewed, however.
Enhanced Debugging Support
MATLAB 5.0 includes more powerful tools for debugging C MEX-files. The
–argcheck option to the mex script provides protection against accidental
misuse of API functions (such as passing NULL pointers). In addition, there is
increased documentation on troubleshooting common problems.
Enhanced Compile Mechanism
MATLAB 5.0 replaces the old cmex and fmex scripts with mex, which will
compile C or FORTRAN MEX-files. All compiler-specific information has been
moved to easily readable and highly configurable options files. The mex script
has a configurable set of flags across platforms and can be accessed from within
MATLAB via the mex.m M-file.
MATLAB 4 Feature Unsupported in MATLAB 5.0
Non-ANSI C Compilers
MATLAB 4 let you compile MATLAB applications with non-ANSI C compilers.
MATLAB 5.0 requires an ANSI C compiler.
2-47
2
MATLAB 5.0 Enhancements
New Platform-Specific Features
MS Windows
Path Browser
The Path Browser lets you view and modify the MATLAB search path. All
changes take effect in MATLAB immediately.
2-48
New Platform-Specific Features
Workspace Browser
The Workspace Browser lets you view the contents of the current MATLAB
workspace. It provides a graphical representation of the traditional whos
output. In addition, you can clear workspace variables and rename them.
2-49
2
MATLAB 5.0 Enhancements
M-File Editor/Debugger
The graphical M-file editor/debugger allows you to set breakpoints and
single-step through M-code. The M-file editor/debugger starts automatically
when a breakpoint is hit. When MATLAB is installed, this program becomes
the default editor.
Command Window Toolbar
A toolbar is now optionally present for the Command Window. The toolbar
provides single-click access to several commonly used operations:
• Open a new editor window
• Open a file for editing
• Cut, copy, paste, and undo
• Open the Workspace Browser
• Open the Path Browser
• Create new Simulink model (if Simulink is installed)
• Access the Help facility
2-50
New Platform-Specific Features
New Dialog Boxes
New Preferences dialog boxes are accessible through the File menu. Some of
these were previously available through the Options menu in MATLAB 4.
There are three categories of preferences:
• General
• Command Window Font
• Copying Options
16-bit Stereo Sound
MATLAB 5.0 now supports 16-bit stereo sound on the Windows platform.
2-51
2
MATLAB 5.0 Enhancements
Macintosh
Two new features available on the Macintosh platform are:
• Japanese characters
It is now possible to generate annotation and string constants that use
Japanese characters.
• 16-bit stereo sound
MATLAB 5.0 now supports 16-bit stereo sound.
User Interface Enhancements
• Optional toolbars in the Command Window, Editor windows, and M-file
debugger allow rapid access to commonly used features.
• Color syntax highlighting in the Command Window, Editor windows, and
M-file debugger provides visual cues for identifying blocks of code,
comments, and strings.
• Almost all lists and text items in the Command Window, Editor, Path
Browser, Workspace Browser, M-file debugger, and Command History
Window have optional dynamic or “live” scrolling; the display is scrolled as
the scroll box of a scrollbar is moved.
• Macintosh Drag and Drop is supported throughout MATLAB for rapid and
easy exchange of text between windows.
Command Window Features
• Typing on the current command line can now be undone and redone. This
includes cutting, clearing, overtyping, dragging, and dropping.
• Placing the caret on an error message and pressing Enter opens the M-file
in the Editor, positioned to the offending line.
2-52
New Platform-Specific Features
Command History Window
The Command History window contains a list of all commands executed from
the Command Window. Commands are saved between MATLAB sessions, so
you can select and execute a group of commands from a previous day’s work to
continue quickly from where you left off.
Path Browser
The Path Browser provides an intuitive, easy-to-use graphical interface for
viewing and modifying the MATLAB search path. You can reorder or modify
the search path simply by dragging items in the path list. Similarly, you can
change the current MATLAB directory by dragging any folder into the current
MATLAB directory area.
2-53
2
MATLAB 5.0 Enhancements
Workspace Browser
The Workspace Browser allows you to view the contents of the current
MATLAB workspace. It provides a graphic representation of the traditional
whos output. You can delete variables from the workspace and sort the
workspace by various criteria. Double-clicking on a workspace variable
displays that variable’s contents in the Command Window.
2-54
New Platform-Specific Features
M-File Debugger
MATLAB 5.0 includes a graphical M-file debugger, which allows you to set
breakpoints and single-step through M-code. Selecting text in the debugger
window and pressing the Enter (not the Return) key evaluates that text in the
Command Window.
2-55
2
MATLAB 5.0 Enhancements
Editor Features
• Command-clicking in the title of an Editor window displays a pop-up menu
containing the full path to the M-file. Selecting a folder from the pop-up
menu opens that folder in the Finder.
• Selecting text in an Editor window and pressing Enter evaluates that text
in the Command Window.
• Typing a close parenthesis, bracket, or brace briefly highlights the matching
open parenthesis, bracket, or brace.
• Double-clicking a parenthesis, bracket, or brace selects all text within the
matching parenthesis, bracket, or brace.
• Line numbers may be optionally displayed.
2-56
New Platform-Specific Features
UNIX Workstations
Figure Window Toolbar
The MATLAB 5.0 Figure window now provides a toolbar with a File pull-down
menu. Selecting the Print option on the File menu activates a set of
pushbuttons that allows easy setting of the most frequently used print options.
2-57
2
MATLAB 5.0 Enhancements
Path Editor
The pathedit command displays a GUI that allows you to view and modify
your MATLAB search path.
2-58
New Platform-Specific Features
Simplified Installation Procedure
The MATLAB 5.0 installation procedure uses a GUI to select or deselect
products and platforms.
2-59
2
MATLAB 5.0 Enhancements
2-60
3
Upgrading to MATLAB 5.1
Upgrading from MATLAB 4 to MATLAB 5.1 . . . . . . 3-2
Converting M-Files to MATLAB 5
. . . . . . . . . . 3-3
Converting MATLAB 4 External Interface Programs to
the MATLAB 5.1 Application Program Interface .
General Considerations . . . . . . . . . . . . . . . .
Windows Considerations . . . . . . . . . . . . . . .
UNIX Considerations . . . . . . . . . . . . . . . . .
Macintosh Considerations . . . . . . . . . . . . . . .
VMS Considerations . . . . . . . . . . . . . . . . .
Conversion . . . . . . . . . . . . . . . . . . . . .
Recoding for MATLAB 5.1 Compliance . . . . . . . . . .
3-18
3-18
3-21
3-22
3-22
3-22
3-23
3-27
3
Upgrading to MATLAB 5.1
Upgrading from MATLAB 4 to MATLAB 5.1
MATLAB 5.1 is a major upgrade to MATLAB 4. Although The MathWorks
endeavors to maintain full upwards compatibility between subsequent releases
of MATLAB, inevitably there are situations where this is not possible. In the
case of MATLAB 5.1, there are a number of changes that you need to know
about in order to migrate your code from MATLAB 4 to MATLAB 5.1.
It is useful to introduce two terms in discussing this migration. The first step
in converting your code to MATLAB 5.1 is to make it MATLAB 5.1 compatible.
This involves a rather short list of possible changes that let your M-files run
under MATLAB 5.1. The second step is to make it MATLAB 5.1 compliant.
This means making further changes so that your M-file is not using obsolete,
but temporarily supported, features of MATLAB. It also can mean taking
advantage of MATLAB 5.1 features like the new data constructs, graphics, and
so on.
There are a relatively small number of things that are likely to be in your code
that you will have to change to make your M-files MATLAB 5.1 compatible.
Most of these are in the graphics area.
There are a somewhat larger number of things you can do (but don’t have to)
to make your M-files fully MATLAB 5.1 compliant. To help you gradually make
your code compliant, MATLAB 5.1 displays warning messages when you use
functions that are obsolete, even though they still work correctly.
Note: This chapter expands upon porting issues discussed in the MATLAB 5
New Features Guide; the additional information is highlighted with change
bars in the left margin.
3-2
Converting M-Files to MATLAB 5.1
Converting M-Files to MATLAB 5.1
This section describes some changes you can make to your code to eliminate
error messages and warnings due to incompatible and noncompliant
statements.
Table 3-1: Language Changes
Function
Change
Action
auread,
auwrite
New syntax.
Change call to use new syntax.
bessel
The bessel functions no longer
produce a table for vector
arguments of the same
orientation.
In besselj(nu,x), specify nu as a row
and x as a column to produce a table.
case,
otherwise,
switch
case, otherwise, and switch
cannot be used as variable names.
Rename your variables.
dialog.m now creates a modal
Use the msgbox function instead.
dialog
dialog.
echo
echo does not display multiline
Update code.
matrices.
end
extra end statements
Remove redundant end statements.
eps
eps is a function
eps = 0 no longer redefines eps for
other functions (it makes a local
variable called eps in the current
workspace). Functions that base their
tolerance on externally defined eps
won’t work. Change code accordingly.
3-3
3
Upgrading to MATLAB 5.1
Table 3-1: Language Changes (Continued)
Function
Change
Action
find
find was modified for sparse row
vectors. find(sparse_row) was a
column in MATLAB 4 and
MATLAB 5.0. Now it produces a
row when the input is a row. All
other cases still return columns.
Update code.
for
for loop variable different after
loop for empty loops. In
MATLAB 4:
Protect the for loop with an isempty
call:
i = 10;
for i = 1:0, %goes nowhere
end
i
produces i = 10. In MATLAB 5.1
it produces i = [].
global
Undefined globals
Define globals before they are used.
Always put the global statement at
the top of the M-file (just below the
help comments).
MATLAB 4 produced a link in the
workspace to an uninitialized global. It
shows up in whos but exist returns 0.
Do not use exist to test for the first
time the global has been accessed. Use
isempty.
gradient
gradient no longer produces
Use two outputs in the
two-dimensional case.
complex output.
input
3-4
i = 10;
if ~isempty(n)
for i=1:n
end
end
i
input('prompt','s') no longer
outputs an initial line feed.
Prompts now show up on the
same line.
Update code accordingly if this causes
a display problem. Add \n in the
prompt string to force a line feed.
Converting M-Files to MATLAB 5.1
Table 3-1: Language Changes (Continued)
Function
Change
Action
interp1
The old interp1 syntax
(interp1(x,n)) no longer calls
interpft. A warning was in place
in MATLAB 4.
Update code accordingly.
interp1 now returns a row vector
when given a row vector. It used
to return a column vector.
Transpose the output of interp1 to
produce the MATLAB 4 result when
xi is a row vector.
interp1('spline') returns
NaN’s for out of range
values.
Use spline directly.
interp2
The old interp2 syntax
(interp2(x,y,xi)) no longer calls
interp1. A warning was in place
in MATLAB 4.
Update code accordingly.
interp3
The old interp3 syntax
(interp3(z,m,n) or
interp3(x,y,z,xi,yi)) no longer
calls griddata. A warning was in
place in MATLAB 4. interp3 is
now three-dimensional
interpolation.
Update code accordingly.
Automeshing
interpolation
commands
Interpolation automeshing has
changed. griddata, interp2,
interp3, interpn, and bessel*
now automesh if (xi,yi) or
(nu,z) are vectors of different
orientations. Previously they
automeshed if the vectors were
different size.
When xi and yi are vectors of the
same orientation but different lengths,
change calls like interp2(...,xi,yi)
to interp2(...,xi,yi').
3-5
3
Upgrading to MATLAB 5.1
Table 3-1: Language Changes (Continued)
Function
Change
Action
isempty
A == [] and A ~= [] as a check
for an empty matrix produce
warning messages.
Use isempty(A) or ~isempty(A). In a
future version A == [] will produce an
empty result.
isspace
isspace only returns true (1) on
strings. isspace(32) is 0 (it was 1
in MATLAB 4).
Wrap your calls to isspace with char.
lasterr
At MATLAB 5.1, lasterr doesn’t
contain the ??? that prints out
when you get an error. Some types
of errors in MATLAB 5.0
erroneously contained ???.
None required.
logical
Some masking operations where
the mask isn’t defined using a
logical expression now produce an
out of range index error.
Wrap the subscript with a call to
logical or use the logical expression
A~=0 to produce MATLAB 4 behavior.
Boolean indexing is no longer
directly supported.
Use logical to create the index array.
matlabrc
On the PC, MATLAB no longer
stores the path in matlabrc.
All platforms except the Macintosh
now use pathdef.m. The Macintosh
still stores its path in the MATLAB
Settings file (usually in the
Preferences folder).
max
max(size(v)), as a means to
determine the number of
elements in a vector v, fails when
v is empty.
Use length(v) in place of
max(size(v)).
max ignores NaNs.
min
3-6
min ignores NaNs.
Converting M-Files to MATLAB 5.1
Table 3-1: Language Changes (Continued)
Function
Change
Action
nargin,nargout
nargin and nargout are
functions.
nargout = nargout–1 (and any
ones
A(ones(size(A))) no longer
produces A.
similar construction) is an error. To
work around this change, assign
nargin to a local variable and
increment that variable. Rename all
occurrences of nargin to the new
variable. The same holds true for all
functions.
This statement produces copies of the
first element of A. Use
A(ones(size(A))~=0) or just A to
produce the MATLAB 4 behavior.
No longer accepts column vector.
Size vector must be a row vector with
integer elements.
Functions such as ones, eye, rand,
and zeros give an error if
supplied with a matrix argument
(such as zeros(A)).
Use the syntax ones(size(A))
instead.
polyfit
Second output now a structure.
Change code to access structure
component.
print
–ocmyk is now –cmyk.
Update code accordingly.
–psdefcset is now –adobecset.
Update code accordingly.
GIF format no longer supported.
Use alternate format.
Texture mapped surfaces do not
print with painter’s algorithm.
Use –zbuffer.
rand('normal') and
rand('uniform') no longer
Use randn for normally distributed
and rand for uniformly distributed
random numbers.
rand
supported.
3-7
3
Upgrading to MATLAB 5.1
Table 3-1: Language Changes (Continued)
Function
Change
Action
round
Subscripts must be integers.
To reproduce MATLAB 4 behavior,
wrap noninteger subscripts with
round(). Strings are no longer valid
subscripts (since they are not integers
in the strict sense).
Set functions:
intersect,
setdiff,
setxor, union,
These functions now error out if
the inputs aren’t vectors, and you
aren’t using the rows flag.
Update code if required.
size
An empty string created within a
MEX-file is now of size 0,0,
consistent with the rest of
MATLAB. (This change occurred
with MATLAB 5.1.)
Update code accordingly.
slice
slice no longer requires the
number of columns (ncols)
argument.
Update code accordingly.
sound
Doesn’t autoscale.
Use soundsc.
strcmp
strncmp
strcmp and strncmp now return
false (0) when any argument is
Call isequal for all nonstrings you
want to compare.
unique
numeric. They used to perform an
isequal.
3-8
text
text(S) when S is a multirow
character array formerly
produced one handle per row. Now
it produces one multiline text
handle.
Rewrite code so that it doesn’t assume
a specific number of handles.
wavread,
wavwrite
New syntax.
Change call to use new syntax.
Converting M-Files to MATLAB 5.1
Table 3-1: Language Changes (Continued)
Function
Change
Action
zeros
No longer accepts column vector.
Size vector must be a row vector with
integer elements.
Note: The following language changes do not directly apply to specific functions.
a(:) = b where a doesn't exist
creates an error. This used to do
the same thing as a = b(:) when
a didn't exist.
Either initialize a or use a = b(:)
instead.
Must use an explicitly empty
matrix to delete elements of an
array, as in a(i) = [] or
a(i,:) = [].
This syntax works for all built-in data
types (including cell arrays and
structures).
The syntax a(i) = B, when B is
empty, no longer deletes elements.
Use a(i) = [] instead.
An attempt to delete elements of
an array outside its range is no
longer (incorrectly) ignored.
An error is generated.
Undefined variables
To reproduce MATLAB 4 behavior,
initialize your variable to the empty
matrix ([]) or empty string ('').
Undefined outputs
To reproduce MATLAB 4 behavior,
initialize your outputs to the empty
matrix ([]).
Indices must be integers. Strings
are no longer valid indices.
Use a(round(ind)) to get MATLAB 4
behavior.
_,^,{, and } are now interpreted,
Use \_,\^, \{, and\}.
not displayed.
Concatenating a string and a
double truncates the double.
Use double to convert the string before
concatenating.
3-9
3
Upgrading to MATLAB 5.1
Table 3-1: Language Changes (Continued)
Function
Change
Action
Input arguments no longer
evaluated left to right.
Evaluate input arguments before
passing them to a function.
String handling difference.
In MATLAB 4
Initialize a to be a character array or
convert it after assignment.
a = 32*ones(1,10);
a(1:5) = 'hello' produces
'hello'. In MATLAB 5.1, it
produces:
104 101 108 11 32 32 32 32 32.
Inline matrix constants and
continued matrix constants inside
function calls:
Put continuation dots and semicolon
after each matrix line.
fun(arg1,[1 2 3
3 4 5,
5 6 6])
are a syntax error.
Table 3-2: Obsolete Language Functions
3-10
Obsolete Function
Action
casesen
Remove the call.
csvread, csvwrite
Use dlmread(filename,',') and dlmwrite(filename,',').
ellipk
Replace with ellipke.
extent
Replaced by Extent property.
figflag
Use findobj.
finite
Rename to isfinite. finite will continue to work in MATLAB 5.1
but will probably be removed in a later release.
fwhich
Use which.
Converting M-Files to MATLAB 5.1
Table 3-2: Obsolete Language Functions (Continued)
Obsolete Function
Action
hthelp
hthelp works in MATLAB 5.1, but will not be further developed or
supported.Use helpwin.
htpp
Use helpwin.
inquire
Use set and get to obtain the current state of an object or of
MATLAB.
inverf
Rename to erfinv.
isdir
Use dir.
layout
No replacement in MATLAB 5.1.
loadhtml
Use helpwin or doc.
matq2ws
Replaced by assignin and evalin.
matqdlg
Replaced by assignin and evalin.
matqparse
Replaced by assignin and evalin.
matqueue
Replaced by assignin and evalin.
menulabel
Bug in Handle Graphics is now fixed.
mexdebug
Rename to dbmex.
ode23p
Use ode23 with no left-hand arguments or set an output function
with odeset.
polyline, polymark
Use the line object or plot.
printmenu
No replacement in MATLAB 5.1.
saxis
Use soundsc.
ws2matq
Replaced by assignin and evalin.
3-11
3
Upgrading to MATLAB 5.1
Table 3-3: Graphics Function Changes
Function
figure
get
Change
Action
In MATLAB 4 if a figure extended
past the top of the window, it was
adjusted to be visible. MATLAB
5.1 performs no adjustment.
Avoid hardcoded Figure positions.
get(h,'currentfigure') and
get(h,'currentaxes') no longer
gcf and gca always return a valid
handle. Use gcf and gca instead of the
get function in this context.
create a Figure or an Axes if one
doesn't exist. They return [] in
that case.
plot
rotate
In MATLAB 4 you could
determine if a graphics object had
a default value set by passing its
handle in a query like
get(gca,'DefaultAxesColor').
In MATLAB 5.1 make the query on the
object’s ancestor, e.g.:
get(gcf,'DefaultAxesColor') or
MATLAB 4 plots may have
elements that are the wrong color.
MATLAB 5.1 defaults to a white
background on all platforms.
(MATLAB 4 defaulted to white on the
Macintosh and black everywhere else.)
Use colordef to control your color
defaults. Typically, you will put a call
to colordef in startup.m. To get the
MATLAB 4 defaults, use colordef
none.
plot line styles c1 through c15
and i are no longer supported
Use a 1-by-3 RGB ColorSpec instead. i
is the same as get(gca,'color') or
get(gcf,'color') when the Axes
color is 'none'.
rotate alpha is reversed from
If your call looked like
MATLAB 4.
get(0,'DefaultAxesColor')
rotate(h,[theta phi],alpha),
change to
rotate(h,[theta phi],–alpha[0 0
0]).
3-12
Converting M-Files to MATLAB 5.1
Table 3-3: Graphics Function Changes (Continued)
Function
Change
Action
uicontrol
The default Uicontrol text
horizontal alignment is centered
in MATLAB 5.1. (In MATLAB 4
we used to left align text and
ignore the alignment property.)
Explicitly set the horizontal alignment
when you create Uicontrol Text
objects.
In MATLAB 4, Uicontrols of style
'edit' executed their callback
routine whenever you moved the
pointer out of the edit box. In
MATLAB 5.1, edit controls
execute their callbacks after you
perform a specific action.
The callback is called when:
• Return key is pressed (single-line
edits only)
• Focus is moved out of the edit by:
• clicking elsewhere in the Figure
(on another Uicontrol or on
another graphical object)
• clicking in another Figure
• clicking on the menu bar (X
Windows only)
Note: The following change does not directly apply to a specific function.
MATLAB 5.1 sets font size
selection to match platform
conventions. A MATLAB 4 font
selection may be a different size
in MATLAB 5.1.
Resize font appropriately.
Table 3-4: Graphics Property Changes
Property
Object Type
Change
Action
AspectRatio
Axes
Obsolete
Replace with
DataAspectRatio and
PlotBoxAspectRatio.
BackgroundColor
Uimenu
Obsolete
Do not use.
3-13
3
Upgrading to MATLAB 5.1
Table 3-4: Graphics Property Changes (Continued)
3-14
Property
Object Type
Change
Action
CDataScaling
Image,
Patch,
Surface
Renamed
CDataMapping
(MATLAB 5.0 Beta
property)
CurrentMenu
Figure
Becoming obsolete. No
warning message
produced.
Replace with the
function gcbo.
EraseMode
Image,
Line, Patch,
Surface,
Text
Now use xor against the
Axes color rather than
the Figure color.
Modify code as
appropriate.
For non-normal
erasemode, MATLAB
recomputes Axes limits
only when you fully
update the display (e.g.,
with a drawnow
command).
Set the Axes limits (and
other properties you
depend upon) before
using non-normal
modes to create
animation.
ExpFontAngle
Axes, Text
Obsolete
Do not use.
ExpFontName
Axes, Text
Obsolete
Do not use.
ExpFontSize
Axes, Text
Obsolete
Do not use.
ExpFontStrikeThrough
Axes, Text
Obsolete
Do not use.
ExpFontUnderline
Axes, Text
Obsolete
Do not use.
ExpFontUnits
Axes, Text
Obsolete
Do not use.
ExpFontWeight
Axes, Text
Obsolete
Do not use.
FontStrikeThrough
Axes, Text
Obsolete
Do not use.
FontUnderline
Axes, Text
Obsolete
Do not use.
Converting M-Files to MATLAB 5.1
Table 3-4: Graphics Property Changes (Continued)
Property
Object Type
Change
Action
HiddenHandle
All graphics
objects
Renamed
HandleVisibility
Line, Patch,
Surface
Setting the LineStyle
property to a marker
value (such as '+') now
produces a warning.
Set the Marker property
instead. Note that plot
will continue to take
line-color marker line
styles.
(MATLAB 5.0 Beta
property)
LineStyle
Setting the marker style
of a line now affects the
Marker property instead
of the LineStyle
property. Although you
will be able to set a line
marker using the
LineStyle property
(with a warning), you
will not be able to get
marker style
information from
LineStyle.
If your code relies on
markers in the
LineStyle, you'll have to
change it to use the
Marker instead.
Light
Renamed
Style
NextPlot
Axes, Figure
Use of value 'new' is
obsolete. Produces
warning message.
Use HandleVisibility
to protect UIs from
command line users.
PaletteMode
Image,
Patch,
Surface
Renamed
CDataMapping
ProjectionType
Axes
Renamed
Projection
Mode
(MATLAB 5.0 Beta
property)
(MATLAB 5.0 Beta
property)
3-15
3
Upgrading to MATLAB 5.1
Table 3-4: Graphics Property Changes (Continued)
Property
Object Type
Change
Action
RenderLimits
Axes
Obsolete
Do not use. Limits are
now always accurate.
SelectionType
Figure
Right mouse button
went from Extended in
MATLAB 4 to Alternate
in MATLAB 5.1.
None required.
Units
Axes,
Figure, Text,
Uicontrol
Units/Position is always
order dependent for all
objects. In MATLAB 4, it
was inconsistent.
The Units property
should precede any
properties that depend
upon it. A command
such as
axes('position',[100
200 300 100],'units',
'pixels') is not the
same as
axes('units','pixels,
'position',[100 200
300 100]). In the first
case the numbers are
interpreted in
normalized coordinates.
WindowID
Figure
Possibly becoming
obsolete.
May be removed in a
future release.
XLim, XTick
Axes
Values must be
monotonically
increasing.
Sort the ticks:
XLoc2D
(MATLAB 5.0 Beta
property)
3-16
Axes
Renamed
set(gca,'xtick',
sort ([3 2 1])
XAxisLocation
Converting M-Files to MATLAB 5.1
Table 3-4: Graphics Property Changes (Continued)
Property
Object Type
Change
Action
XTickLabels
Axes
Renamed
XTickLabel
YLim, YTick
Axes
Values must be
monotonically
increasing.
Sort the ticks:
set(gca,'ytick',
sort ([3 2 1])
Axes
Renamed
YAxisLocation
YTickLabels
Axes
Renamed
YTickLabel
ZLim, ZTick
Axes
Values must be
monotonically
increasing.
Sort the ticks:
YLoc2D
(MATLAB 5.0 Beta
property)
ZTickLabels
Axes
Renamed
set(gca,'ztick',
sort ([3 2 1])
ZTickLabel
3-17
3
Upgrading to MATLAB 5.1
Converting MATLAB 4 External Interface Programs to the
MATLAB 5.1 Application Program Interface
MATLAB 4 External Interface programs, including MEX-files, MAT-file
programs, and Engine programs may run without any modification on the
MATLAB 5.1 Application Program Interface (API), or they may require
modification and/or recompilation. The following pages and flowcharts describe
how to determine which of these possibilities applies in your situation and how
to choose the appropriate conversion technique.
General Considerations
Non-ANSI C Compilers
MATLAB 4 let you compile External Interface programs with non-ANSI C
compilers. MATLAB 5.1 API header files include strict prototyping of API
functions and require an ANSI C compiler.
MATLAB Character Strings
MATLAB 4 and MATLAB 5.1 represent string data in different ways.
MATLAB 4 supported only one data type. All data was represented as
double-precision, floating-point numbers, even individual characters in a
string array. A numerical array and a character array differed only by how
MATLAB displayed these values. MATLAB 5.1 represents each character in a
string array as an mxChar, a 16-bit unsigned integer data type. If the mxArray’s
class is mxCHAR_CLASS, the API treats each number in the mxArray as an
element from the current character set. Character sets are platform specific.
External Interface programs that call the API routines mxGetString() and
mxCreateString() to manipulate strings continue to work. All MEX-files that
directly manipulate strings must be rewritten. MAT-file and Engine
applications which directly manipulate strings need not be rewritten.
However, to recompile these applications under MATLAB 5.1, any code that
directly manipulates strings must be rewritten. We highly recommend that you
use the API string access and creation routines to do this. To help in this
endeavor, we have added a new C routine,
mxCreateCharMatrixFromStrings(), in addition to mxGetString() and
mxCreateString(), to make it easy to create two-dimensional string matrices.
3-18
Converting MATLAB 4 External Interface Programs to the MATLAB 5.1 Application Program Interface
MEX-File Argument Complexification
In MATLAB 4, if one argument to a MEX-function was complex, all arguments
were passed as complex. This is not true in MATLAB 5.1. For example,
consider a MEX-function, myeig(A,B,C), that calculates eigenvalues of three
matrices. In MATLAB 4, if matrix A is complex, B and C are assumed to be
complex matrices as well. In this instance, additional memory is allocated for
the complex part of B and C, and initialized with zero values.
MATLAB 5.1 does not allocate this memory for you. If your MEX-file assumes
argument complexification, you will have to rewrite your MEX-file. Each
argument to a MEX-function needs to be tested with mxIsComplex() to
guarantee that an argument indeed has a complex component.
Type Imputation by Process of Elimination
In MATLAB 4 the only way to determine if a matrix was a full, non-string
matrix was by a process of elimination. For example, if your code checked a
variable and found that it was a full matrix (nonsparse), and was not a string,
you could also assume that the variable was double-precision, floating-point
and two-dimensional. In MATLAB 5.1, with the addition of several new data
types and support for multidimensional data, this assumption is no longer
valid. mxIs* routines and mxGetNumberOfDimensions() have been added to the
C interface so that now you can explicitly check arguments for specific data
types and shapes. mxIsDouble(), which always returned 1 in MATLAB 4, now
correctly returns 1 only if the mxArray is of type double precision floating point.
mxIsDouble() is available in C as well as Fortran. mxGetN() returns the total
number of elements in dimensions 2-n, and therefore works correctly with
multidimensional as well as two dimensional arguments.
Version 3.5 MEX-Files
MEX-files generated under MATLAB 4 using the –v3.5 switch to the cmex or
fmex script are no longer supported and must be rewritten. Refer to both the
MATLAB 4 External Interface Guide for information on upgrading to MATLAB
4 syntax and the section in this document on recoding for MATLAB 5.1
compliance.
3-19
3
Upgrading to MATLAB 5.1
Simulink
By design, Simulink S-functions written in C must be recompiled under the
latest version of Simulink. The code is source compatible, but the binary must
be recompiled. If you attempt to run a Simulink 1.3 C S -function under
Simulink 2.1, you get an appropriate warning message. Simulink S-functions
written in Fortran do not have this restriction.
Fortran MEX-File Considerations
The MATLAB Fortran API has not changed from MATLAB 4 to MATLAB 5.1.
However, Fortran mex users on Windows, 68K Macintosh and the SUN4 must
recompile their applications, using the mex script for programs that call
mxCreateString() or mxGetString(). Only these platforms, which statically
link in the Fortran interface, are affected. No recompilation is required on
other platforms.
Rebuilding MEX-Files Loaded in Memor y
In MATLAB 4, on Windows and UNIX, you could execute cmex or fmex from
within MATLAB by using the ! command or execute in another window. These
methods are no longer supported with MATLAB 5.1. However, the M-file,
mex.m, that builds MEX files is available on all platforms and can safely rebuild
loaded MEX files by unloading them before proceeding with the build. The
interface provided by the M-file is identical to the external mex script.
Default MEX-File Optimization
In MATLAB 4 MEX-files by default were built with no optimization flags
passed to the compiler. In MATLAB 5.1 the default is to optimize MEX-files.
See the MATLAB Application Program Interface Guide for more information.
Debugging MEX-Files
The –debug switch to cmex/fmex is no longer supported. Instead, on all
platforms, MATLAB 5.1 supports MEX-file debugging from within a MATLAB
session. (See the debugging sections of the MATLAB Application Program
Interface Guide for more details). In addition, the mex script has been enhanced
with the –argcheck switch that provides a way for C mex users to generate code
to check input and output arguments at runtime and issue appropriate error
messages if invalid data is detected.
3-20
Converting MATLAB 4 External Interface Programs to the MATLAB 5.1 Application Program Interface
MAT-File External Applications
MAT-file external applications built under MATLAB 4 will continue to work
under MATLAB 5.1. Note that the MAT-file format has changed between
MATLAB 4 and MATLAB 5.1. Although MATLAB will be able to read
MATLAB 4 MAT-files generated by a stand-alone program, stand-alone
programs will not be able to read MAT-files in a MATLAB 5.1 format. You can
generate MATLAB 4 MAT-files from MATLAB 5.1 by specifically passing the
–v4 switch to the save command.
Windows Considerations
MEX-files are generated under MATLAB 5.1 as 32-bit DLLs. The cmex and
fmex batch files have been superseded by mex (a PERL script) and a set of
compiler-specific option files. These compilers are fully supported for creating
MEX or stand-alone applications through MathWorks-supplied option files:
• Watcom C
• Microsoft Visual C++
• Borland C
Microsoft Fortran, currently the only supported Fortran compiler, is supported
for MEX applications only. You will not be able simply to recompile your
MATLAB 4 Fortran MEX-file source with this new compiler. See “Creating
Fortran MEX-files” in the MATLAB Application Program Interface Guide for
further information.
NDP Fortran, previously supported under MATLAB 4, is not supported in this
release.
16-bit DLL MEX-files are no longer supported and cannot be generated.
Existing MATLAB 4 REX MEX-files are usable but cannot be created under
MATLAB 5.1.
See “Fortran MEX-file Considerations” above for Windows-specific restrictions
on creating and accessing MATLAB character strings.
MATLAB 4 C language Engine binaries will not run with MATLAB 5.1.
Programs must be recompiled. MATLAB 5.1 data types are currently not
supported on the PC from an Engine program. There is currently no support
for Fortran Engine or MAT-file programs.
3-21
3
Upgrading to MATLAB 5.1
See the MAATLAB Application Program Interface Guide for instructions on
compiling stand-alone programs in MATLAB 5.1.
UNIX Considerations
The cmex and fmex Bourne shell scripts for building MEX-files have been
superseded by mex, also a Bourne shell script, that sources an options file,
mexopts.sh for all platform compiler-specific information. The options file
contains all the pertinent compiler and linker switches for building ANSI C
and Fortran MEX-file applications. The .mexrc.sh file is no longer supported
and must be converted to the new format. The mexdebug MATLAB command
that allows UNIX users to debug their MEX-files while MATLAB is running
has been changed to dbmex. The behavior of dbmex under MATLAB 5.1 is
identical to mexdebug under MATLAB 4.
See “Fortran Considerations” above for SUN4-specific restrictions on creating
and accessing MATLAB character strings.
You can use your existing UNIX Engine and MAT-file binary files unmodified;
no recompilation is necessary. Note that MATLAB 4 Engine programs have no
access to new MATLAB 5.1 data types. If you try to invoke
engGetMatrix(ep,my_variable), and my_variable is a cell array, structure
array, object, etc., the operation automatically fails.
Macintosh Considerations
The Absoft MacFortran and Symantec Think C compilers are no longer
supported.
MEX-files built under MATLAB 4 with MPW C on the 68K Macintosh that call
the following I/O routines must be recompiled: putc(), getc(), ferror(),
feof(), clearerr().These exist as macros in MPW’s stdio.h. In MATLAB 5.1,
these functions have been reimplemented as function callbacks to MATLAB.
See “Fortran MEX-file Considerations” above for 68K Macintosh-specific
restrictions on creating and accessing MATLAB character strings.
VMS Considerations
MEX-files compiled for MATLAB 4 on the VMS platform are not binary
compatible. You must regenerate these files from source code before using
them with MATLAB 5.1.
3-22
Converting MATLAB 4 External Interface Programs to the MATLAB 5.1 Application Program Interface
Conversion
Rebuilding MEX-Files
The simplest strategy for converting C MEX-file programs is to rebuild them
with the special –V4 option of mex. This option uses mex to define a macro
V4_COMPAT that supports MATLAB 4 syntax and function calls. Therefore, any
ANSI C MEX-file source code that compiled cleanly under MATLAB 4 should
compile cleanly with the –V4 option. The resulting MEX-file should run under
MATLAB 5.1 just as it ran under MATLAB 4. For example, given C MEX-file
MATLAB 4 source code in file MyEig.c, recompiling under UNIX with
mex –V4 myeig.c
yields a MEX-file that MATLAB 5.1 can execute. It is also possible to use cmex
and fmex for compiling C and Fortran source code, but both of these functions
simply call mex.
The obvious advantage to the –V4 strategy is that it requires very little work
on your part. However, this strategy provides only a temporary solution to the
conversion problem; there is no guarantee that future releases of MATLAB will
continue to support the –V4 option. If you have the time, recoding for
MATLAB 5.1 compliance is a better strategy. See “Recoding for MATLAB 5.1
Compliance” below.
Rebuilding Stand-Alone MAT-File and Engine Programs
If your source code is ANSI compliant, you can recompile your source without
modification by using the compiler flag –DV4_COMPAT. This allows you to avoid
recoding, such as rewriting obsolete function calls as their MATLAB 5.1
equivalents. However, the resulting program will have the same restrictions as
existing binary files.
See the MATLAB Application Program Interface Guide for instructions on
compiling stand-alone programs in MATLAB 5.1.
MEX-file Conversion Flowcharts
The flowcharts below help you determine what steps you should take to run
your MATLAB 4 MEX-files under MATLAB 5.1.
3-23
3
Upgrading to MATLAB 5.1
Start
Determine if you can use your
MATLAB 4 MEX-file binary
as is.
Cannot use your
Stop
MATLAB 4 MEX-file
yes
binary or source as is.
Are you running on
VMS
?
Was MEX-file source
generated by MATLAB
compiler?
no
no
Stop
Refer to MATLAB 4
yes
API documentation.
Are you using a 16-bit
dll onWindows
?
Was MEX-file
built with the –V3.5
switch?
Was MEX-file
built with MPW C on
68K Mac & does it call file
I/O routines
?
Is C MEX-file
a Simulink
S-function?
no
Does MEX-file
identify datatypes by process
of elimination?
no
Does MEX-file
assume argument
complexification?
Stop
yes
Does MEX-file
use MATLAB access routines to
manipulate string matrices
?
yes
no
yes
Cannot use your
MATLAB 4 MEX-file
binary as is.
yes
no
yes
Are you running
on Sun 4, 68K Mac, or
Windows?
yes
no
no
Is MEX-file
written in Fortran
?
yes
no
no
yes
yes
no
Does MEX-file
directly manipulate string
matrices?
yes
Cannot use your
MATLAB 4 MEX-file
binary as is.
no
You can use your MATLAB 4
MEX-file binary as is.
Stop
3-24
Stop
Converting MATLAB 4 External Interface Programs to the MATLAB 5.1 Application Program Interface
Start
Determine if you can rebuild
with the –V4 option of mex.
Can your platform
compiler generate MATLAB 5
MEX-files?
no
Acquire a MATLAB 5.1
compliant compiler.
yes
Was MEX-file
source generated by
MATLAB compiler?
yes
Cannot rebuild with
–V4 option of mex.
Stop
no
Does MEX-file
identify data types by
process of elimination?
yes
Rewrite code so that it
explicitly checks for the data
types you want.
no
Does MEX-file
assume argument
complexification?
yes
Rewrite code so that it does
not assume complexification
of arguments.
no
Does MEX-file
directly manipulate string
matrices?
yes
Convert direct manipulation of
string matrices to use access
and creation routines.
no
Does MEX-file
contain non-ANSI C code
?
yes
Rewrite non-ANSI C code
as ANSI C code.
no
Does MEX-file
use printf
?
yes
Rewrite using mexPrintf,
make sure to include mex.h.
no
Stop
Does MEX-file
include cmex.h
?
no
yes
Include mex.h.
Rebuild your MEX-file sources
using the MATLAB 5.1 script
mex –V4 filename
3-25
3
Upgrading to MATLAB 5.1
Start
Determine if you can compile
with mex filename.
Can your platform
compiler generate MATLAB 5
MEX-files?
no
Acquire a MATLAB 5.1
C or Fortran
compliant compiler.
yes
yes
Is your source
written in Fortran
?
no
Was MEX-file source
generated by MATLAB
compiler?
yes
Rebuild source with
MATLAB 5.1 compatible
M-file compiler.
no
Is your source
MATLAB 5.1 compliant
?
yes
no
Change all Matrix variables
to mxArray variables.
Translate obsolete function calls
to their MATLAB 5.1 replacements.
Change REAL to mxREAL, and
COMPLEX to mxCOMPLEX.
Rewrite code to explicitly handle
new MATLAB 5.1 data types.
Change all Real variables to
double variables.
Recompile with mex filename.
Rewrite mexFunction call
to comply with MATLAB 5.1
prototyping.
3-26
Stop
Converting MATLAB 4 External Interface Programs to the MATLAB 5.1 Application Program Interface
Recoding for MATLAB 5.1 Compliance
Recoding your MATLAB 4 C code for MATLAB 5.1 compliance involves:
• Rewriting any non-ANSI C code as ANSI C code. (For details, see an ANSI C
book.)
• Changing all Matrix variables to mxArray variables.
The MATLAB 4 Matrix data type is obsolete; you must change all Matrix
variables to mxArray variables. For example, the mxCreateSparse function
returns a Matrix pointer in MATLAB 4:
Matrix *MySparse;
MySparse = mxCreateSparse(10,10,110,REAL);
To be MATLAB 5.1 compliant, change the code to:
mxArray *MySparse;
MySparse = mxCreateSparse(10,10,110,mxREAL);
• Rewriting all function prototypes.
The function prototype of almost every MATLAB 4 function is different in
MATLAB 5.1. The two primary prototype changes are
- All Matrix arguments are now mxArray arguments.
- Pointers to read only data are now declared as const *.
• For MEX-files, rewriting mexFunction to take a constant mxArray * as a
fourth argument.
• Changing REAL to mxREAL and COMPLEX to mxCOMPLEX.
In any function that requires the specification of real or complex data types,
instead of REAL and COMPLEX, use mxREAL and mxCOMPLEX. For example, in
MATLAB 4 you would write
mxCreateSparse(m,n,nzmax,REAL);
to create an m-by-n sparse matrix with nzmax nonzero real elements. In
MATLAB 5.1, the correct syntax for this same function is:
mxCreateSparse(m,n,nzmax,mxREAL);
• Translating obsolete function calls into their MATLAB 5.1 replacements.
A number of functions have become obsolete. However, MATLAB 5.1 offers
replacements for nearly all obsolete functions.
3-27
3
Upgrading to MATLAB 5.1
• Handling MATLAB 5.1 new data types.
You should explicitly check the data type of your input arguments to ensure
that you have what you want.
Table 3-5 lists MATLAB 4 External Interface functions along with a
description of how to recode those functions to work with MATLAB 5.1.
Table 3-5: Recoding MATLAB 4 Functions for MATLAB 5.1 Compliance
3-28
MATLAB 4 Function
MATLAB 5.1 Replacement
engGetMatrix
engGetArray
engGetFull
engGetArray followed by calls to the appropriate
mx* routines
engPutMatrix
engPutArray
engPutFull
mxCreateDoubleMatrix followed by engPutArray
engSetEvalCallback
Windows platform only. Obsolete in MATLAB 5.1.
engSetEvalTimeout
Windows platform only. Obsolete in MATLAB 5.1.
engWinInit
Windows platform only. Obsolete in MATLAB 5.1.
matGetMatrix
matGetArray
matGetNextMatrix
matGetNextArray
matGetFull
matGetArray followed by calls to the appropriate
mx* routines
matPutMatrix
matPutArray
matPutFull
mxCreateDoubleMatrix followed by matPutArray
mexAtExit
No change
mexCallMATLAB
Second and fourth arguments are mxArray *
mexErrMsgTxt
No change
mexEvalString
No change
Converting MATLAB 4 External Interface Programs to the MATLAB 5.1 Application Program Interface
Table 3-5: Recoding MATLAB 4 Functions for MATLAB 5.1 Compliance
(Continued)
MATLAB 4 Function
MATLAB 5.1 Replacement
mexFunction
Second and fourth arguments are mxArray * .
Fourth argument is a const.
mexGetEps
Obsolete; call mxGetEps instead.
mexGetFull
Obsolete; call this sequence instead:
mexGetArray(array_ptr, "caller");
name = mxGetName(array_ptr);
m = mxGetM(array_ptr);
n = mxGetM(array_ptr);
pr = mxGetPr(array_ptr);
pi = mxGetPi(array_ptr);
mexGetGlobal
Obsolete; call mexGetArrayPtr instead, setting
the second argument to "global". Note: it is
better programming practice to call
mexGetArray(,"global");
mexGetInf
Obsolete; call mxGetInf instead
mexGetMatrix
Call mexGetArray(name,"caller");
mexGetMatrixPtr
Call mexGetArrayPtr(name,"caller");
mexGetNaN
Obsolete; call mxGetNaN instead.
mexIsFinite
Obsolete; call mxIsFinite instead.
mexIsInf
Obsolete; call mxIsInf instead.
mexIsNaN
Obsolete; call mxIsNaN instead.
mexPrintf
No change.
3-29
3
Upgrading to MATLAB 5.1
Table 3-5: Recoding MATLAB 4 Functions for MATLAB 5.1 Compliance
(Continued)
MATLAB 4 Function
MATLAB 5.1 Replacement
mexPutFull
Obsolete; call this sequence instead:
mxArray *parray;
int retval;
parray = mxCreateDouble(0,0,0);
if(parray == (mxArray*)0) return(1);
mxSetM(parray,m);
mxSetN(parray,n);
mxSetPr(parray,pr);
mxSetPi(parray,pi);
mxSetName(parray,name);
retval = mxPutArray(parray,"caller");
mxFree(parray);
return(retval);
3-30
mexPutMatrix
Obsolete; call mexPutArray instead.
mexSetTrapFlag
No change
mxCalloc
No change
mxCreateFull
Obsolete; call mxCreateDoubleMatrix instead.
mxCreateSparse
Returns mxArray *.
mxCreateString
Returns mxArray *.
mxFree
No change
mxFreeMatrix
Obsolete; call mxDestroyArray instead.
mxGetIr
First argument is mxArray *.
mxGetJc
First argument is mxArray *.
mxGetM
First argument is mxArray *.
mxGetN
First argument is mxArray *.
Converting MATLAB 4 External Interface Programs to the MATLAB 5.1 Application Program Interface
Table 3-5: Recoding MATLAB 4 Functions for MATLAB 5.1 Compliance
(Continued)
MATLAB 4 Function
MATLAB 5.1 Replacement
mxGetName
First argument is mxArray *.
mxGetNzmax
First argument is mxArray *.
mxGetPi
First argument is mxArray *.
mxGetPr
First argument is mxArray *.
mxGetScalar
First argument is mxArray *.
mxGetString
First argument is mxArray *.
mxIsComplex
First argument is mxArray *.
mxIsDouble
First argument is mxArray *.
Note that MATLAB 4 stores all data as doubles;
MATLAB 5.1 stores data in a variety of integer
and real formats.
mxIsFull
Obsolete; call !mxIsSparse instead.
mxIsNumeric
First argument is mxArray *.
mxIsSparse
First argument is mxArray *.
mxIsString
Obsolete; call mxIsChar instead.
mxSetIr
First argument is mxArray *.
mxSetJc
First argument is mxArray *.
mxSetM
First argument is mxArray *.
mxSetN
First argument is mxArray *.
mxSetName
First argument is mxArray *.
mxSetNzmax
First argument is mxArray *.
mxSetPi
First argument is mxArray *.
3-31
3
Upgrading to MATLAB 5.1
Table 3-5: Recoding MATLAB 4 Functions for MATLAB 5.1 Compliance
(Continued)
3-32
MATLAB 4 Function
MATLAB 5.1 Replacement
mxSetPr
First argument is mxArray *.
mxSetString
Obsolete; MATLAB 5.1 provides no equivalent
call since the mxArray data type does not contain
a string flag. Use
mxCreateCharMatrixFromStrings to create
multidimensional string mxArrays.
Index
A
addpath function 2-13
auwrite 3-3
airy function 2-15
Axes object 2-27, 3-14
Axes properties
align function 2-45
alignment tool 2-45
AmbientLightColor 2-36
AmbientLightColor property 2-36
CameraPosition 2-36
AmbientStrength property 2-39, 2-41
CameraPositionMode 2-36
API
cell array support 2-46
compiler location 1-16
enhancements for the Macintosh 1-16, 1-17
fundamental data type 2-46
mexopts.bat file 1-16
multidimensional array support 2-46
nonANSI C compilers 2-47
nondouble data 2-46
setup option 1-16
stucture support 2-46
See also function, API
Application Program Interface
CameraTarget 2-36
CameraTargetMode 2-36
CameraUpVector 2-36
CameraUpVectorMode 2-36
CameraViewAngle 2-36
CameraViewAngleMode 2-36
DataAspectRatio 2-36
DataAspectRatioMode 2-36
FontUnits 2-36
Layer 2-36
NextPlot 2-36
PlotBoxAspectRatio 2-36
PlotBoxAspectRatioMode 2-37
ProjectionType 2-37
See API
Application Program Interface See API
application toolboxes
enhancements 1-4
area function 2-24
array
empty 2-19
string 2-10
array editing
on the Macintosh 1-8
AspectRatio property 3-13
assignin function 2-13
assignment enhancements 2-17
asterisk
as wildcard 2-19
auread 3-3
autumn colormap 2-28
TickDirMode 2-37
XAxisLocation 2-37
YAxisLocation 2-37
B
BackgroundColor property 3-13
bar charts 2-24
bar3 function 2-24
bar3h function 2-24
barh function 2-24
base2dec function 2-10
bessel functions 3-3
besselh function 2-15
bicg function 2-16
bicgstab function 2-16
I-1
Index
bin2dec function 2-10
bitand function 2-17
bitcmp function 2-17
bit-manipulation 2-17
bitmax function 2-17
bitor function 2-18
bitset function 2-18
bitshift function 2-18
bittest function 2-17
bitxor function 2-18
box function 2-25
browser
path 2-48, 2-53
workspace 2-49, 2-54
BusyAction property 2-35
C
calendar function 2-15
callback editor 2-45
CallbackObject property 2-40
camera properties 2-26
CameraPosition property 2-36
CameraPositionMode property 2-36
CameraTarget property 2-36
CameraTargetMode property 2-36
CameraUpVector property 2-36
CameraUpVectorMode property 2-36
CameraViewAngle property 2-36
CameraViewAngleMode property 2-36
case statement 2-12
casesen 3-10
cat function 2-6, 2-7
cbedit function 2-45
CData property 2-38, 2-39, 2-41
CDataMapping property 3-14, 3-15
CDataScaling property 2-38, 2-39, 2-41, 3-14
I-2
cell array 2-6, 2-8
API support 2-46
cell function 2-8
cell2struct function 2-8
celldisp function 2-8
cellplot function 2-8
cells function 2-8
cgs function 2-16
char function 2-10
character set, Japanese 2-52
Children property 2-35
cholinc function 2-16
clabel function 2-26
class function 2-11
CloseRequestFcn property 2-37
CodeWarrior 11 1-17
color enhancements 2-27
Color property 2-38
colorcube colormap 2-28
colordef 2-27
colormap
autumn 2-28
colorcube 2-28
lines 2-28
spring 2-28
summer 2-28
winter 2-28
Communications Toolbox 1.2 1-4
compatibility 3-2
compiler location 1-16
compilers
CodeWarrior 11 1-17
compliance 3-2
condeig function 2-15
condest function 2-15
Continue
in debugger 1-8
Index
contourf function 2-26
contouring enhancements 2-26
control, flow 2-11
convhull function 2-21
CreateFcn property 2-35
csvread function (obsolete) 3-10
csvwrite function (obsolete) 3-10
cumprod function 2-18
cumsum 2-18
cumsum function
dimension specifier 2-18
cumtrapz function 2-21
CurrentMenu property 3-14
D
data analysis features 2-21
data constructs 2-6
cell array 2-6, 2-8
multidimensional array 2-6
object 2-6
structure 2-6, 2-8
data hiding 2-9
data visualization 2-25
DataAspectRatio property 2-36
DataAspectRatioMode property 2-36
date functions 2-15
datenum function 2-15
datestr function 2-15
datetick function 2-15, 2-25
datevec function 2-15
dblquad function 2-15
dbmex function 3-11
debugger
Continue 1-8
step 1-8
debugger, Macintosh 2-55
dec2base function 2-10
dec2bin function 2-10
delaunay function 2-21
DeleteFcn property 2-35
device drivers
JPEG 1-12, 1-13
TIFF 1-12
device options
print command 2-30
dialog box
modal 2-44, 3-3
non-modal 2-44
dialog function 2-29, 3-3
DiffuseStrength property 2-39, 2-41
dimension specification 2-18
DithemapMode property 2-37
Dithermap property 2-37
dlmread function 3-10
dlmwrite function 3-10
documentation viii
double integration 2-15
dragrect function 2-44
dsearch function 2-21
DSP Blockset 2.0 1-4
E
echo function 3-3
edit function 2-13
editor
callback 2-45
menu 2-45
property 2-45
editor, Macintosh 2-56
Editor/Debugger
for Windows 2-50
editpath function 2-13
I-3
Index
I-4
eigs function 2-16
F
ellipk function (obsolete) 3-10
FaceLightingAlgorithm property 2-39, 2-41
ellipke function 3-10
Faces property 2-39
empty array 2-19
checking for 3-6
multidimensional 2-19
empty matrix 2-19
checking for 3-6
Enable property 2-42, 2-43
Encapsulated PostScript 1-15
end statements, extra 3-3
engGetFull function 3-28
engGetMatrix function 3-28
engPutFull function 3-28
engPutMatrix function 3-28
engSetEvalCallback function 3-28
engSetEvalTimeout function 3-28
engWinInit function 3-28
eomday function 2-15
eps 3-3
EPS files 1-15
EraseMode property 2-38, 3-14
erfinv function 3-11
ErrorMessage property 2-40
ErrorType property 2-40
evalin function 2-13
ExpFontAngle property 3-14
ExpFontName property 3-14
ExpFontSize property 3-14
ExpFontStrikeThrough property 3-14
ExpFontUnderline property 3-14
ExpFontUnits property 3-14
ExpFontWeight property 3-14
extent function (obsolete) 3-10
eye function 3-7
factor function 2-21
features
Macintosh 2-52
MS Windows 2-48
platform-specific 2-48
UNIX workstations 2-57
fieldnames function 2-9
figflag function (obsolete) 3-10
figure 3-12
Figure properties
CloseRequestFcn 2-37
Dithermap 2-37
DithermapMode 2-37
IntegerHandle 2-37
NextPlot 2-37
PaperPositionMode 2-37
PointerShapeCData 2-37
PointerShapeHotSpot 2-37
Renderer 2-37
RendererMode 2-38
Resize 2-38
ResizeFcn 2-38
find 3-4
find function 1-7
finite function (obsolete) 3-10
Fixed-Point Blockset 1.0.2 1-4
flipdim function 2-7
flow control 2-11
case 2-12
switch 2-11
FontAngle property 2-42
FontName property 2-42
FontSize property 2-42
FontStrikeThrough property 3-14
Index
FontUnderline property 3-14
mexIsInf 3-29
FontUnits property 2-36, 2-42
mexIsNaN 3-29
FontWeight property 2-42
mexPrintf 3-29
for 3-4
mexPutFull 3-30
fullfile function 2-14
mexPutMatrix 3-30
function
mexSetTrapFlag 3-30
addpath 2-13
mxCalloc 3-30
airy 2-15
mxCreateFull 3-30
align 2-45
mxCreateSparse 3-30
API
mxCreateString 3-30
dbmex 3-11
mxFree 3-30
engGetFull 3-28
mxFreeMatrix 3-30
engGetMatrix 3-28
mxGetIr 3-30
engPutFull 3-28
mxGetJc 3-30
engPutMatrix 3-28
mxGetM 3-30
engSetEvalCallback 3-28
mxGetN 3-30
engSetEvalTimeout 3-28
mxGetName 3-31
engWinInit 3-28
mxGetNzmax 3-31
matGetFull 3-28
mxGetPi 3-31
matGetMatrix 3-28
mxGetPr 3-31
matGetNextMatrix 3-28
mxGetScalar 3-31
matPutFull 3-28
mxGetString 3-31
matPutMatrix 3-28
mxIsComplex 3-31
mexAtExit 3-28
mxIsDouble 3-31
mexCallMATLAB 3-28
mxIsFull 3-31
mexdebug 3-11
mxIsNumeric 3-31
mexErrMsgTxt 3-28
mxIsSparse 3-31
mexEvalString 3-28
mxIsString 3-31
mexFunction 3-29
mxSetIr 3-31
mexGetEps 3-29
mxSetJc 3-31
mexGetFull 3-29
mxSetM 3-31
mexGetGlobal 3-29
mxSetN 3-31
mexGetInf 3-29
mxSetName 3-31
mexGetMatrix 3-29
mxSetNzMax 3-31
mexGetMatrixPtr 3-29
mxSetPi 3-31
mexGetNaN 3-29
mxSetPr 3-32
mexIsFinite 3-29
mxSetString 3-32
I-5
Index
function (continued)
area 2-24
assignin 2-13
bar3 2-24
bar3h 2-24
barh 2-24
base2dec 2-10
bessel 3-3
besselh 2-15
bicg 2-16
bicgstab 2-16
bin2dec 2-10
bitand 2-17
bitcmp 2-17
bitmax 2-17
bitor 2-18
bitset 2-18
bitshift 2-18
bittest 2-17
bitxor 2-18
box 2-25
calendar 2-15
cat 2-6, 2-7
cbedit 2-45
cell 2-8
cell2struct 2-8
celldisp 2-8
cellplot 2-8
cells 2-8
cgs 2-16
char 2-10
cholinc 2-16
clabel 2-26
class 2-11
condeig 2-15
condest 2-15
contourf 2-26
I-6
convhull 2-21
csvread 3-10
csvwrite 3-10
cumprod 2-18
cumsum 2-18
cumtrapz 2-21
datenum 2-15
datestr 2-15
datetick 2-15, 2-25
datevec 2-15
dblquad 2-15
dec2base 2-10
dec2bin 2-10
delaunay 2-21
dialog 2-29, 3-3
dimension specification 2-18
dlmread 3-10
dlmwrite 3-10
dragrect 2-44
dsearch 2-21
echo 3-3
edit 2-13
editpath 2-13
eigs 2-16
ellipk 3-10
ellipke 3-10
eomday 2-15
erfinv 3-11
evalin 2-13
extent 3-10
eye 3-7
factor 2-21
fieldnames 2-9
figflag 3-10
finite 3-10
flipdim 2-7
fullfile 2-14
Index
function (continued)
fwhich 3-10
gallery 2-16
gca 3-12
gcf 3-12
get 3-11, 3-12
getfield 2-9
gmres 2-16
gradient 3-4
griddata 2-22
guide 2-45
hthelp 3-11
http 3-11
ind2sub 2-8
inferiorto 2-11
inmem 2-14
inpolygon 2-21
input 3-4
inputdlg 2-44
inputname 2-14
inquire 3-11
interp1 3-5
interp2 3-5
interp3 2-22, 3-5
interpn 2-22
intersect 2-22
inverf 3-11
ipermute 2-7
isa 2-11
iscell 2-12
isdir 3-11
isempty 3-6
isequal 2-12
isfinite 2-12
islogical 2-12
ismember 2-22
isnumeric 2-12
isprime 2-21
isspace 3-6
isstruct 2-12
layout 3-11
loadhtml 3-11
logical 2-12
luinc 2-16
mat2str 2-10
matq2ws 3-11
matqdlg 3-11
matqparse 3-11
matqueue 3-11
max 2-20, 3-6
menuedit 2-45
menulabel 3-11
mexext 2-14
mfilename 2-14
min 2-20, 3-6
mod 2-15
msgbox 2-44, 3-3
nargin 3-7
nargout 3-7
nchoosek 2-21
ndgrid 2-7, 2-22
ndims 2-7
normest 2-15
now 2-15
num2cell 2-8
ode113 2-16
ode15s 2-16
ode23 2-16, 3-11
ode23p 3-11
ode23s 2-16
ode45 2-16
odefile 2-16
odeget 2-16
odeset 2-16, 3-11
I-7
Index
function (continued)
ones 3-7
otherwise 2-12
pathedit 2-58
pcg 2-17
pcode 2-14
perms 2-21
permute 2-7
pie 2-24
pie3 2-24
plot 3-11, 3-12
plotyy 2-24
polyarea 2-21
polyline 3-11
polymark 3-11
primes 2-21
printmenu 3-11
prod 2-18, 2-20
profile 2-14
propedit 2-45
qmr 2-17
quiver3 2-25
rand 3-7
rbbox 2-44
repmat 2-16
reshape 2-7
ribbon 2-25
rmfield 2-9
rmpath 2-14
saxis 3-11
selectmoveresize 2-44
set 3-11
setdiff 2-22
setfield 2-9
setxor 2-22
shiftdim 2-7
slice 2-26, 3-8
I-8
sortrows 2-21
soundsc 3-11
sprand 2-16
squeeze 2-8
stem 2-25
stem3 2-25
strcat 2-10
strcmp 3-8
strmatch 2-10
strncmp 2-10, 3-8
struct 2-9
struct2cell 2-9
structs 2-9
strvcat 2-10
sub2ind 2-8
sum 2-18, 2-20
superiorto 2-11
svds 2-17
trimesh 2-26
trisurf 2-26
tsearch 2-21
union 2-22, 2-23
unique 2-22, 2-23
voronoi 2-21
web 2-14
weekday 2-15
ws2matq 3-11
zeros 3-7
function reference viii
functions
time and date 2-15
fundamental data type, API 2-46
FVCData property 2-39
fwhich function (obsolete) 3-10
Index
G
H
gallery function 2-16
Handle Graphics 1-11
HandleVisibility property 2-35, 3-15
Help Desk vii
HiddenHandle property 3-15
hthelp function (obsolete) 3-11
http function (obsolete) 3-11
gca function 3-12
gcf function 3-12
general graphics features 2-29
get function 3-11, 3-12
getfield function 2-9
global variable 3-4
gmres function 2-16
gradient function 3-4
graphical user interface See GUI
graphics object
Axes 2-28, 3-14
defaults 2-29
Line 3-11
Patch 2-26
Text 2-28
graphics object properties
BusyAction 2-35
Children 2-35
CreateFcn 2-35
DeleteFcn 2-35
HandleVisibility 2-35
Interruptible 2-35
Parent 2-35
Selected 2-35
SelectionHighlight 2-35
Tag 2-35
griddata function 2-22
GUI
general enhancements 2-44
improvements 2-44
Guide 2-45
guide function 2-45
I
if expressions 2-12
Image Processing Toolbox 2.0 1-4
Image properties
CData 2-38
CDataScaling 2-38
EraseMode 2-38
image support 2-31
ind2sub function 2-8
inferiorto function 2-11
initializing
outputs 3-9
variables 3-9
inmem function 2-14
input function
no initial linefeed 3-4
inputdlg function 2-44
inputname function 2-14
inquire function (obsolete) 3-11
integer bit manipulation functions 2-17
integer subscripts 3-8
IntegerHandle property 2-37
interp1 function 3-5
interp2 function 3-5
interp3 function 2-22, 3-5
interpn function 2-22
I-9
Index
interpolation
higher-dimension 2-22
triangle-based 2-22
Interpreter property 2-42
Interruptible property 2-35
intersect function 2-22
inverf function (obsolete) 3-11
ipermute function 2-7
ipolygon function 2-21
isa function 2-11
iscell function 2-12
isdir function (obsolete) 3-11
isempty function 3-6
isequal function 2-12
isfinite function 2-12
islogical function 2-12
ismember function 2-22
isnumeric function 2-12
isprime function 2-21
isspace function 3-6
isstruct function 2-12
J
Japanese character set 2-52
JPEG device driver 1-12
K
Kanji 1-7
L
lasterr 3-6
Layer property 2-36
layout function (obsolete) 3-11
legend function 2-25
I-10
Light properties
Color 2-38
Mode 2-38
Position 2-38
Line object 3-11
Line properties
HandleVisibility 3-15
HiddenHandle 3-15
LineStyle 3-15
Marker 2-39, 3-15
MarkerEdgeColor 2-39
MarkerFaceColor 2-39
Mode 3-15
Style 3-15
line styles 3-12
lines colormap 2-28
LineStyle property 2-39, 3-15
List Box object 2-44
ListboxTop property 2-43
loadhtml function (obsolete) 3-11
logical function 2-12
luinc function 2-16
M
Macintosh
editing arrays 1-8
Path Browser 1-9
Mapping Toolbox 1-20
Marker property 2-39, 2-41, 3-15
MarkerEdgeColor property 2-39, 2-41
MarkerFaceColor property 2-39, 2-41
MarkerSize property 2-39, 2-41
masking 3-6
mat2str function 2-10
matGetFull function 3-28
matGetMatrix function 3-28
Index
matGetNextMatrix function 3-28
mexPutFull function (obsolete) 3-30
matPutFull function 3-28
mexPutMatrix function (obsolete) 3-30
matPutMatrix function 3-28
mexSetTrapFlag function 3-30
M-file
profiling 2-13
programming tools 2-13
pseudocode 2-13
variable number of arguments 2-13
with multiple functions 2-13
mfilename function 2-14
min function 3-6
with empty argument 2-20
mod function 2-15
modal dialog box 2-44, 3-3
Mode property 2-38, 3-15
mouse pointer 2-44
msgbox function 2-44, 3-3
multibyte characters 1-7
multidimensional array 2-6
API support 2-46
empty 2-19
multiple functions within an M-file 2-13
mxCalloc function 3-30
mxCreateFull function 3-30
mxCreateSparse function 3-30
mxCreateString function 3-30
mxFree function 3-30
mxFreeMatrix function (obsolete) 3-30
mxGetIr function 3-30
mxGetJc function 3-30
mxGetM function 3-30
mxGetN function 3-30
mxGetName function 3-31
mxGetNzmax function 3-31
mxGetPi function 3-31
mxGetPr function 3-31
mxGetScalar function 3-31
matq2ws function (obsolete) 3-11
matqdlg function (obsolete) 3-11
matqparse function (obsolete) 3-11
matqueue function (obsolete) 3-11
matrix
empty 2-19
max function 3-6
with empty argument 2-20
menlabel function 3-11
menu editor 2-45
menuedit function 2-45
meshes
and triangulation 2-26
methods, sparse matrices 2-16
mexAtExit function 3-28
mexCallMATLAB function 3-28
mexdebug function (obsolete)
obsolete 3-11
mexErrMsgTxt function 3-28
mexEvalString function 3-28
mexext function 2-14
mexFunction function 3-29
mexGetEps function (obsolete) 3-29
mexGetFull function (obsolete) 3-29
mexGetGlobal function 3-29
mexGetGlobal function (obsolete) 3-29
mexGetInf function (obsolete) 3-29
mexGetMatrix function 3-29
mexGetMatrixPtr function 3-29
mexGetNaN function (obsolete) 3-29
mexIsFinite function(obsolete) 3-29
mexIsInf function (obsolete) 3-29
mexIsNaN function (obsolete) 3-29
mexPrintf function 3-29
I-11
Index
mxGetString function 3-31
O
mxIsComplex function 3-31
object 2-6
Axes 2-27
List Box 2-44
Patch 2-26
Text 2-28
object-oriented programming 2-9
objects 2-9
obsolete functions 3-10
ode113 function 2-16
ode15s function 2-16
ode23 function 2-16
ode23 function (obsolete) 3-11
ode23p function (obsolete) 3-11
ode23s function 2-16
ode45 function 2-16
odefile function 2-16
odeget function 2-16
odeset function 2-16
odeset function(obsolete) 3-11
Office 97 1-7
ones 3-7
ones function
with matrix inputs 3-7
otherwise function 2-12
outputs
initializing 3-9
overloading 2-10
mxIsDouble function 3-31
mxIsFull function (obsolete) 3-31
mxIsNumeric function 3-31
mxIsSparse function 3-31
mxIsString function (obsolete) 3-31
mxSetIr function 3-31
mxSetJc function 3-31
mxSetM function 3-31
mxSetN function 3-31
mxSetName function 3-31
mxSetNzmax function 3-31
mxSetPi function 3-31
mxSetPr function 3-32
mxSetString function (obsolete) 3-32
N
nargin function 3-7
nargout function 3-7
nchoosek function 2-21
ndgrid function 2-7, 2-22
ndims function 2-7
NextPlot property 2-36, 2-37, 3-15
nonANSI C compilers 2-47
nondouble data
API support 2-46
non-modal dialog box 2-44
NormalMode property 2-40, 2-41
normest function 2-15
nosplash 2-44
Notebook 1-7
now function 2-15
num2cell function 2-8
I-12
P
PaletteMode property 3-15
PaperPositionMode property 2-37
Parent property 2-35
Patch object 2-26
Index
Patch properties
polyarea function 2-21
AmbientStrength 2-39
polyline function (obsolete) 3-11
CData 2-39
polymark function (obsolete) 3-11
CDataScaling 2-39
Position property 2-38
DiffuseStrength 2-39
Postscript 1-15
primes function 2-21
print function 2-30
changes to 3-7
print function 1-12, 1-15
print options
generating M-file to recreate figure 2-30
PostScript bounding box 2-30
Uicontrol objects 2-30
user-selectable Z-buffer resolution 2-30
printing 1-12, 1-15
patches 1-11
sufaces 1-11
printmenu function (obsolete) 3-11
prod function 2-18
with empty argument 2-20
Product Tour 1-6
profile function 2-14
profiler 2-13
programming
object-oriented 2-9
programming tools 2-13
ProjectionType property 2-37, 3-15
ProjectionTyper property 3-15
propedit function 2-45
property
AspectRatio 3-13
BackgroundColor 3-13
CDataMapping 3-14, 3-15
CDataScaling 3-14
CurrentMenu 3-14
EraseMode 3-14
ExpFontAngle 3-14
FaceLightingAlgorithm 2-39
Faces 2-39
FVCData 2-39
LineStyle 2-39
Marker 2-39
MarkerEdgeColor 2-39
MarkerFaceColor 2-39
MarkerSize 2-39
NormalMode 2-40
SpecularColorReflectance 2-40
SpecularExponent 2-40
SpecularStrength 2-40
VertexNormals 2-40
Vertices 2-40
patches
printing 1-11
Path Browser 2-48, 2-53
on the Macintosh 1-9
pathedit function 2-58
pcg function 2-17
pcode function 2-13, 2-14
perms function 2-21
permute function 2-7
pie function 2-24
pie3 function 2-24
plot function 3-11, 3-12
PlotBoxAspectRatio property 2-36
PlotBoxAspectRatioMode property 2-37
plotting capabilities 2-24
plotyy function 2-24
PointerShapeCData property 2-37
PointerShapeHotSpot property 2-37
I-13
Index
property (continued)
ExpFontName 3-14
ExpFontSize 3-14
Q
qmr function 2-17
quiver3 function 2-25
ExpFontStrikeThrough 3-14
ExpFontUnderline 3-14
ExpFontUnits 3-14
R
ExpFontWeight 3-14
rand function 3-7
FontStrikeThrough 3-14
with matrix inputs 3-7
random number generation 3-7
rbbox function 2-44
Real-Time Workshop 1-4
relationship to Stateflow 1-19
Renderer property 2-37
RendererMode property 2-38
RenderLimit property 3-16
repmat function 2-16
reshape function 2-7
Resize property 2-38
ResizeFcn property 2-38
ribbon function 2-25
rmfield function 2-9
rmpath function 2-14
Root properties
CallbackObject 2-40
ErrorMessage 2-40
ErrorType 2-40
ShowHiddenHandles 2-40
TerminalDimensions 2-40
TerminalHideGraphCommand 2-40
TerminalShowGraphCommand 2-41
FontUnderline 3-14
Mode 3-15
NextPlot 3-15
PaletteMode 3-15
ProjectionType 3-15
RenderLimit 3-16
SelectionType 3-16
Style 2-29
Units 3-16
WindowID 3-16
XAxisLocation 3-16
XLim 3-16
XLoc2D 3-16
XTick 3-16
XTickLabel 3-17
XTickLabels 3-17
YAxisLocation 3-17
YLim 3-17
YLoc2D 3-17
YTick 3-17
YTickLabel 3-17
YTickLabels 3-17
ZLim 3-17
ZTick 3-17
ZTickLabel 3-17
ZTickLabels 3-17
property editor 2-45
pseudocode 2-13
I-14
S
saxis function (obsolete) 3-11
scalar expansion for subarray assignments 2-17
scatter function 1-11
Selected property 2-35
Index
SelectionHighlight property 2-35
SelectionType property 3-16
selectmoveresize function 2-44
set function 3-11
set theoretic functions 2-22
setdiff function 2-22
setfield function 2-9
setxor function 2-22
shiftdim function 2-7
ShowHiddenHandles property 2-40
Simulink 1-4
relationship to Stateflow 1-19
size 3-8
slice function 2-26, 3-8
SliderStep property 2-43
sortrows function 2-21
sound 3-8
soundsc 3-8
soundsc function 3-11
sparse matrices 2-16
SpecularColorReflectance property 2-40, 2-41
SpecularExponent property 2-41
SpecularExponentproperty 2-40
SpecularStrength property 2-40, 2-42
splash screen
suppressing on UNIX system 2-44
sprand function 2-16
spring colormap 2-28
squeeze function 2-8
startup file 2-29
Stateflow 1-11
relationship to Real-Time Workshop 1-19
relationship to Simulink 1-19
Stateflow Coder 1-19
stem function 2-25
stem3 function 2-25
step
in debugger 1-8
stereo sound
Macintosh 2-51, 2-52
PC 2-51, 2-52
strcat function 2-10
strcmp function
with numeric inputs 3-8
string array 2-10
strmatch function 2-10
strncmp function 2-10
with numeric inputs 3-8
struct function 2-9
struct2cell function 2-9
structs function 2-9
structure 2-6, 2-8
API support 2-46
strvcat function 2-10
Style property 2-29, 2-43, 3-15
sub2ind function 2-8
subscripting enhancements 2-17
subscripts
must be integers 3-8
sum function
dimension specifier 2-18
with empty argument 2-20
summer colormap 2-28
superiorto function 2-11
Surface properties
AmbientStrength 2-41
CData 2-41
CDataScaling 2-41
DiffuseStrength 2-41
FaceLightingAlgorithm 2-41
FontUnits 2-42
Interpreter 2-42
Marker 2-41
I-15
Index
Surface properties (continued)
MarkerEdgeColor 2-41
MarkerFaceColor 2-41
MarkerSize 2-41
NormalMode 2-41
triangular surfaces 2-26
trimesh function 2-26
trisurf function 2-26
truecolor 2-32
tsearch function 2-21
SpecularColorReflectance 2-41
SpecularExponent 2-41
SpecularStrength 2-42
U
VertexNormals 2-42
Uicontrol
text alignment 3-13
uicontrol function 3-13
Uicontrol object
List Box 2-44
Uicontrol properties
Enable 2-42
FontAngle 2-42
FontName 2-42
FontSize 2-42
FontUnits 2-42
FontWeight 2-42
ListboxTop 2-43
SliderStep 2-43
Style 2-43
Uimenu properties
Enable 2-43
uiresume command 2-45
uisetcolor function 1-11
uiwait command 2-45
union function 2-22, 2-23
unique function 2-22, 2-23
Units property 3-16
upgrading
from MATLAB 4 to MATLAB 5.1 1-2
from MATLAB 5.0 to MATLAB 5.1 1-2
Vertices 2-42
surfaces
printing 1-11
surfaces, triangulation 2-26
svds function 2-17
switch statement 2-11, 2-12
Symbolic Math Toolboxes 2.0 1-4
T
Tag property 2-35
TCP/IP 1-7
TerminalDimensions property 2-40
TerminalHideGraphCommand property 2-40
TerminalShowGraphCommand property 2-41
TeX commands 2-28
text 3-8
Text object 2-28
TeX commands 2-28
texture-mapped patches and surfaces 1-11
TickDirMode property 2-37
TIFF
device driver 1-12
preview images for encapsulated PostScript
1-15
time functions 2-15
triangle-based interpolation 2-22
triangular meshes 2-26
I-16
Index
V
XLoc2D property 3-16
varargin 2-13, 2-14
XTick property 3-16
varargout 2-13, 2-14
XTickLabel property 3-17
variable number of inputs to M-files 2-13
variable number of outputs for M-files 2-13
variable, global 3-4
variables
names 3-3
variables, initializing 3-9
version
compatibility 3-2
compliance 3-2
VertexNormals property 2-40, 2-42
Vertices property 2-40, 2-42
viewing model 2-26
vis3d option 2-27
visualization, data 2-25
voronoi function 2-21
XTickLabels property 3-17
W
waitfor command 2-45
warning 2-14
wavread 3-8
Y
YAxisLocation property 2-37, 3-17
YLim property 3-17
YLoc2D property 3-17
YTick property 3-17
YTickLabel property 3-17
YTickLabels property 3-17
Z
Z-buffering 2-29
printing Z-buffer images 2-30
zeros function
with matrix inputs 3-7
ZLim property 3-17
ZTick property 3-17
ZTickLabel property 3-17
ZTickLabels property 3-17
wavwrite 3-8
web function 2-14
weekday function 2-15
wildcard for utility commands 2-19
WindowID property 3-16
winter colormap 2-28
Workspace Browser 2-49, 2-54
ws2matq function (obsolete) 3-11
X
XAxisLocation property 2-37, 3-16
XLim property 3-16
I-17
Index
I-18
Was this manual useful for you? yes no
Thank you for your participation!

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Download PDF

advertisement