MATLAB Release Notes |
Programming and Data Types Features
MATLAB 6.5 adds the following programming and data types features and enhancements:
JIT Accelerator with MATLAB
MATLAB 6.5 includes significant changes in the way MATLAB processes M-file functions and scripts. These changes affect the performance of MATLAB and can give you a substantial performance increase over earlier MATLAB versions for many MATLAB applications.
Speeding up the execution of programs written in MATLAB is an ongoing MathWorks endeavor that will be delivered over a number of product releases. The documentation on Performance Acceleration explains how to best make use of the JIT Accelerator, how to use the MATLAB Profiler to optimize your performance, and includes several sample programs to illustrate how you can make your M-file programs run faster.
Regular Expression Support
MATLAB now supports searching and replacing characters using regular expressions. The following new functions support this capability. For more information, see Regular Expressions in the MATLAB documentation.
Function |
Description |
regexp |
Match regular expression. |
regexpi |
Match regular expressions, ignoring case. |
regexprep |
Replace string using regular expression. |
New Functions
MATLAB 6.5 added new functions for working with error generation, regular expressions, sorted sets, integer conversion, and for performing file operations.
Function |
Description |
false |
False array |
fileattrib |
Set or get attributes of file or directory |
int64 |
Convert to signed 64-bit integer |
isequalwithequalnans |
Determine if arrays are numerically equal, treating NaNs as equal |
issorted |
Determine if set elements are in sorted order |
lasterror |
Return last error message and related information |
movefile |
Move file or directory |
orderfields |
Order fields of a structure array |
perl |
Call Perl script using appropriate operating system executable |
rethrow |
Reissue error |
rmdir |
Remove directory |
true |
True array |
uint64 |
Convert to unsigned 64-bit integer |
winopen |
Open file in appropriate application (Windows only) |
xmlread |
Parse XML document and return Document Object Model node |
xmlwrite |
Serialize XML Document Object Model node |
xslt |
Transform XML document using XSLT engine |
Cell to Matrix Conversion Functions
The following functions, previously belonging to the Neural Network Toolbox, are now core MATLAB functions.
Function |
Description |
cell2mat |
Combine a cell array of matrices into one matrix |
mat2cell |
Break matrix up into a cell array of matrices |
New Warning and Error Handling Features
Formatted Error and Warning Strings. Prior to MATLAB 6.5, the error
and warning
functions only accepted a simple string as an input argument, as shown here for error
:
In MATLAB 6.5, error
and warning
now accept a format string and one or more parameters, using a syntax similar to the MATLAB sprintf
function. The syntax for error
is shown here. Use the same syntax for warning
:
Examples for using this syntax with error
and warning
are
Message Identifiers. A message identifier is a tag that you attach to an error or warning statement that makes that error or warning uniquely recognizable by MATLAB. You can use message identifiers with warnings to control any selected subset of the warnings in your programs, or with error reporting to better identify the source of an error.
Some examples of message identifiers are
Message identifiers are used in warning control (see next section) and also to enable the lasterr
and lasterror
functions to better identify the source of an error.
See Using Message Identifiers with lasterr in the MATLAB documentation.
Warning Control Features. In this release, MATLAB gives you the ability to control what happens when a warning is encountered during M-file program execution. New options available in this release include
Depending on how you set up your warning controls, you can have these actions affect all warnings in your code, specific warnings that you select, or just the most recently invoked warning. See the section Warning Control in the MATLAB documentation for more information on this feature.
Also read the section, Warning Control Upgrade Issues in these Release Notes to see how your existing programs might be affected by this change.
Dynamic Field Names for Structures
You can now reference structures using field names that are computed at run-time using the new dynamic field names feature in MATLAB. The dot-parentheses syntax shown below tells MATLAB to interpret expression
as a dynamic field name:
This added capability now completes the following table by providing full dynamic access to all data types.
Data Type |
Static (compile time) |
Dynamic (run-time) |
Matrix |
A(2,3) |
A(m,n) |
Cell Array |
C{4} |
C{k*2} |
Structure |
S.name |
S.(field) |
See Dynamic Field Names in the MATLAB documentation for more information on this feature.
getfield and setfield Deprecated. Although the following two expressions are functionally equivalent, the first (using dynamic field names) offers improved execution speed and code readability. Compare the following for readability:
Since dynamic field names improve on the getfield
and setfield
functions, these two functions will eventually be removed from the MATLAB language. As of this release, getfield
and setfield
generate a warning message encouraging you to use dynamic field names instead.
New Logical AND and OR Operators for Short-Circuiting
Prior to this release, the MATLAB &
(AND
) and |
(OR
) operators served two purposes: that of a logical operator and also an array operator. These two roles at times conflicted, resulting in technically correct, yet possibly confusing evaluations.
MATLAB 6.5 introduces two additional AND
and OR
operators: && and ||. Use these new operators to evaluate a compound logical expression, especially when short-circuiting is required. Use the & and | operators for element-wise operations on arrays.
See Short-circuit Operators in the MATLAB documentation for a discussion on short-circuiting with &&
and ||
.
New Output from ismember
The ismember
function now returns an optional, second output indicating the indices at which members of a set are located. The syntax is
When you use this syntax, ismember
returns index vector loc
containing the highest index in S
for each element in A
that is a member of S
. For those elements of A
that do not occur in S
, ismember
returns 0
.
a = reshape(1:5, [5 1]) set = [5 2 4 2 8 10 12 2 16 18 20 3]; [tf, index] = ismember(a, set); index index = 0 8 12 3 1
New true and false Functions
MATLAB has two new functions for logical operations: true
and false
. true
is shorthand for logical(1)
and false
for logical(0)
. Both functions accept input arguments that enable you to build n-dimensional arrays of logical 1
or 0
.
This example builds a 3-by-5 array of type logical
:
true(n)
is equivalent to logical(ones(n))
, however true(n)
is easier to use and will improve the readability of your program. Type help true
or help false
for more information.
Interrupting try-catch in a Loop
try
-catch
statements no longer catch Ctl+C interrupts. Prior to this release, pressing Ctl+C while a try
block was executing would result in a jump to the corresponding catch
block. In MATLAB 6.5, a Ctl+C aborts execution and returns control to the Command Window, regardless of what code is executing.
For example, in MATLAB 6.5, you can use Ctl+C to interrupt the loop shown here. You could not interrupt this loop in earlier MATLAB versions:
Changes to copyfile and mkdir
The copyfile
and mkdir
functions have changed since the previous release.
Changes to copyfile. The writable
argument has been superseded by the f
argument, although writable
is still allowed for this release. The function now also copies directories. It replaces the destination files or directories of the same name as the source files or directories without a warning. (In previous versions, there was a warning in that event.) If the destination files or directories are read-only and the f
(or writable
) argument is not used, copyfile
will fail.
Change to mkdir Return Status. mkdir
no longer returns 2
if the directory already exists, but instead displays a warning. It also has an enhanced return format.
mfilename Returns Path and Class Information
You can now request more information from the mfilename
function:
mfilename('fullpath')
-- Returns the full path and name of the M-file in which the call occurs, not including the filename extension.
mfilename('class')
-- In a method, returns the class of the method, not including the leading @
sign. If called from a non-method, it yields the empty string.
Support for the 64-Bit Integers int64 and uint64
MATLAB now supports signed and unsigned 64-bit integers. Use the int64
and uint64
functions to convert a number to a signed or unsigned 64-bit integer.
64-Bit File Handling
MATLAB low-level file handling functions (fopen
, fseek
, ftell
, etc.) now support 64-bit file offsets. This enables you to perform low-level I/O operations on files greater than 2 GB in size. (The limit in previous versions of MATLAB was 2^31-1
bytes, or 2 GB.)
64-bit support is available on the following platforms:
64-bit support is not available on the following platforms, due to limitations imposed by their respective operating systems:
On the IBM-AIX platform, 64-bit file I/O is supported for reading only. You can write only up to 2 GB.
MATLAB Audio Enhancements
New audiodevinfo Function. On Windows 32-bit machines, audiodevinfo
returns information about installed audio devices.
UNIX Platform Support for audiorecorder and audioplayer.. audioplayer
and audiorecorder
are now available on UNIX platforms running Java Runtime Environment 1.3 or higher.
Enhancements to audiorecorder and audioplayer. audioplayer
and audiorecorder
can now take the audio device ID as input. You can obtain the device ID from audiodevinfo
.
audioplayer
can now take an audiorecorder
as an input.
Support for 24-bit Recording and Playback. On 32-bit Windows machines with an installed 24-bit audio device, audiorecorder
and audioplayer
now support 24-bit recording and playback, respectively.
Improvement to wavread and wavwrite. wavread
and wavwrite
now support reading and writing 24- and 32-bit .wav
files.
Workspace Browser Support. Right-clicking on an audio object in the Workspace Browser now displays a context menu with player/recorder controls.
New MATLAB Timer Object
MATLAB includes a timer object that you can use to schedule the execution of MATLAB commands. To use a timer, you must perform these steps:
timer
function.
start
or startat
functions.
Mathematics Features | Programming Tips Documentation |