Skip to Main Content Skip to Search
Product Documentation

Programming, MATLAB Version 7.1 (R14SP3)

New features and changes are organized by these topics:

New Functions

This version introduces the following new functions:

Function

Description

arrayfun

Applies a given function to each element of an array. This is especially useful for arrays of structures.

exifread

Reads EXIF information from JPEG and TIFF image files

structfun

Applies a given function to each field of a structure

swapbytes

Swaps byte ordering

typecast

Converts data types without changing underlying data

Compatibility Considerations

A new function name can potentially introduce a backward incompatibility since it can, under certain circumstances, override a variable with the same name as the new function. This is especially true for names that are commonly used as variable names in program code. Read the section Variable Names in the MATLAB Programming documentation to find out how to avoid having these variables misinterpreted.

Modified Functions

The following functions were modified in this version:

Function

Modified Behavior

cellfun

Applies a given function to each cell of a cell array

datestr

Seconds field truncates instead of rounding

error

Saves stack information that you can retrieve using lasterror

isfield

Supports cell array input

lasterror

Returns stack information on last error

rethrow

Accepts stack information as input

who, whos

Displays information separately for nested functions

Compatibility Considerations

The following functions might, under certain circumstances, return a different value than what was returned in MATLAB 7.0.4 (R14SP2):

Evaluation Functions for Arrays, Structures, Cells

MATLAB offers the capability to apply a given function to each element of an array, each field of a structure, or each cell of a cell array. See the help on arrayfun, structfun, and cellfun for more information.

Using who and whos with Nested Functions

When you use who or whos inside of a nested function, MATLAB returns or displays all variables in the workspace of that function, and in the workspaces of all functions in which that function is nested. This applies whether you include calls to who or whos in your M-file code or if you call who or whos from the MATLAB debugger. See thewho reference page for more information.

Date and Time Functions Support Milliseconds

The datestr, datenum, and datevec functions now support time specification in milliseconds. Use the symbol .FFF to represent milliseconds in any of these three functions. See the table labeled Free-Form Date Format Specifiers on the datestr reference page for more information.

Stack Trace Provided for lasterror

The lasterror function now returns an additional field in the structure that it returns. The new stack field contains information from the stack on the M-file, function, and line in which the error occurred.

You can use this stack information to track down the source of an error, or as an input to the rethrow function. When used with rethrow, MATLAB sets the stack of the rethrown error to the value contained in the stack input.

isfield Function Supports Cell Arrays; Results Might Differ from Previous Version

The isfield function now supports cell array input as shown in this example. Check structure S for any of four possible field names. In this case, only the first is found, so the first element of the return value is set to true:

S = struct('one', 1, 'two', 2);

fields = isfield(S, {'two', 'pi', 'One', 3.14})
fields =
     1     0     0     0

Compatibility Considerations

There might be backward compatibility issues associated with this change if you used isfield with cell array input in a previous release. In previous releases, although isfield might have worked with this type of input in certain cases, it was not officially a supported feature. If you used this previously unsupported syntax in previous releases, you may see a change in the content and/or size of the return values in this release.

For example, create a structure s with three fields a, b, and c created in that order. In MATLAB 7.0.4, isfield called with a cell array input returns true if any of the elements of the cell array matches a field name, and if that element is in the same position in the cell array as the field is in the structure. This is true for 'c':

isfield(s, {'b'; 'a'; 'c'})
ans =
     1

In MATLAB 7.1, isfield returns true for each element in the cell array that matches a field name, regardless of where the string is positioned in the cell array. This is true for 'a', 'b', and 'c':

isfield(s, {'b'; 'a'; 'c'})
ans =
     1
     1
     1

Support for Reading EXIF Data from Image Files

You can now read EXIF (Exchangeable Image File Format) data from JPEG and TIFF graphics files using the new exifread function. EXIF is a standard used by digital camera manufacturers to store information in the image file, such as the make and model of a camera, the time the picture was taken and digitized, the resolution of the image, exposure time, and focal length.

Performance Improvements to the MATLAB JIT/Accelerator on Macintosh

The JIT/Accelerator for MATLAB, introduced in MATLAB Version 6.5 for Windows and UNIX, is now also supported on Macintosh systems. The JIT/Accelerator affects the performance of MATLAB and can give you a substantial performance increase over earlier MATLAB versions for many MATLAB applications.

Specifying fread Precision as Number of Bits

The following information on the fread function applies to MATLAB 7.1 and also to earlier versions.

MATLAB provides the following method of specifying a precision argument in a call to fread:

input_format=>output_format

For example, to read 50 8-bit unsigned integers from a file and convert them to characters, you can use

c = fread(fid, 50, 'uint8=>char')'

If the input format and output format are the same, you can abbreviate the precision specifier by using

*input_format

For example, you can replace

c = fread(fid, 50, 'uint8=>uint8')'

with

c = fread(fid, 50, '*uint8')'

You can also use this notation with an input stream that is specified as a number of bits (e.g., bit4 or ubit18). MATLAB translates this into an output type that is a signed or unsigned integer (depending on the input type), and which is large enough to hold all of the bits in the source format. For example, *ubit18 does not translate to ubit18=>ubit18, but instead to ubit18=>uint32.

Seconds Field Now Truncated; Results Might Differ

When handling time data, MATLAB now truncates the seconds field instead of rounding it. This is consistent with the way that MATLAB handles hours and minutes.

For example, using MATLAB 7.0.4 (R14SP2), datestr returns

t = datestr('11:30:01.666')
t =
   01-Jan-2005 11:30:02

while MATLAB 7.1 (R14SP3) returns

t = datestr('11:30:01.666')
t =
   01-Jan-2005 11:30:01

Compatibility Considerations

If your M-files relied on the previous behavior, you might get different results.

Built-in Functions No Longer Use .bi; Impacts Output of which Function

In previous releases, MATLAB function dispatching located built-in functions by means of special files having a .bi file extension. MATLAB no longer uses this mechanism to locate built-in functions. All .bi files have been removed in MATLAB 7.1.

Compatibility Considerations

If you have M-files that relied on built-in files having a .bi extension, your files need to accommodate this change.

There are changes in how MATLAB displays built-in functions using which:

In MATLAB 7.0.4 (R14SP2),

which -all int32
\\matlab\toolbox\symbolic\@sym\int32.m          % sym method
\\matlab\toolbox\matlab\datatypes\int32.bi      % Shadowed 
\\matlab\toolbox\matlab\datatypes\int32.m       % Shadowed

In MATLAB 7.1 (R14SP3),

which -all int32
built-in (\\matlab\toolbox\matlab\datatypes\int32)
\\matlab\toolbox\symbolic\@sym\int32.m          % sym method

New Warning About Potential Naming Conflict

If you change directories (cd) or add a new directory to your current MATLAB path, and the new directory contains an M-file having the same name as a MATLAB built-in function, MATLAB now displays a warning alerting you to the potential naming conflict. For example,

Warning: Function D:\test\matlab\disp.m has the same name as a 
MATLAB builtin. We suggest you rename the function to avoid a 
potential name conflict.

In general, any file system event that leads to path refreshing in MATLAB can trigger this warning if the directory involved in this event has such a user function under it.

Compatibility Considerations

MATLAB might generate warnings about naming conflicts that did not appear in previous versions. To avoid this warning, renaming your M-files that have name conflicts with built-in functions.

  


Recommended Products

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

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