Products & Services Solutions Academia Support User Community Company

Learn more about MATLAB   

Programming Fundamentals, MATLAB Version 7.7 (R2008b)

New features and changes introduced in this version are

Fast Key Lookup Provided with New Map Data Structure

This release introduces a new MATLAB class called a Map. An object of the Map class is an array of any MATLAB data type that supports lookup table functionality. Unlike most arrays in MATLAB that only allow access to the elements by means of integer indices, indices for Map containers can be nearly any scalar numeric value or a character string.

The following example creates a Map object that is an array of strings. It is very much like any other string array except that with each value of this array there is also a lookup key associated with it. This particular Map contains the names of capital cities in the United States. These are the values of the Map object. Associated with each capital city value is the US state that it resides in. These are the keys of the Map object. You look up values in the Map using key indices. Call the containers.Map constructor to create an array of six capital cities indexed by six US states. (The capital of Alaska has purposely been entered incorrectly):

US_Capitals = containers.Map( ...
{'Arizona', 'Nebraska', 'Nevada', ...       % 6 States
 'New York', 'Georgia', 'Alaska'}, ...
{'Phoenix', 'Lincoln', 'Carson City', ...   % 6 Capitals
 'Albany', 'Atlanta', 'Fairbanks'});	

Show the capitals of three of the states by looking them up in the Map using the string indices 'Nevada', 'Alaska' and 'Georgia':

values(US_Capitals, {'Nevada', 'Alaska', 'Georgia'})
ans = 
    'Carson City'    'Fairbanks'    'Atlanta'

Correct the capital city of Alaska by overwriting the entry at string index 'Alaska':

US_Capitals('Alaska') = 'Juneau';

US_Capitals('Alaska')
ans =
   Juneau

The term containers.Map refers to a Map class that is part of a MATLAB package called containers. For more information, see Map Containers in the Programming Fundamentals documentation.

Tic and Toc Support Multiple Consecutive Timings

The tic and toc timing functions now support multiple consecutive timings. Call tic with an output t0 to save the current time as the starting time for some operation. When the operation completes, call toc with the same t0 as its input and MATLAB displays the time between that particular tic and toc.

In the following example, MATLAB measures the time used by each function call and, at the same time, measures the time required for the overall operation:

t0 = tic;
   t1 = tic;   W = myfun1(A,B);        toc(t1)
   t2 = tic;   [X,Y] = myfun2(C,W);    toc(t2)
   t3 = tic;   Z = myfun3(A,C,Y);      toc(t3)
toc(t0)

You can still call tic and toc without any arguments. In this case, toc just measures the time since the most recent tic.

See the function reference page for tic or toc for more information.

New Options for MException getReport

The MException getReport method has several new options available in this release. You select these options when you call getReport. They give you more control over the content and format of the information displayed or returned by getReport.

See the function reference page for getReport for more information.

what Function Returns Package Information

The what function now includes package information in its output display and a package field in the structure array that it returns.

List the packages used in the MathWorks Communications Toolbox™:

s = what('comm');

s.packages
ans = 
    'crc'
    'commdevice'
    'commsrc'
    'commgui'
    'commscope'
    'commutils'

You can also call what on a specific package name to see what types of directories and files are in the package directory.

See the function reference page for what for more information.

addtodate Accepts Hours, Minutes, Seconds, Milliseconds

In previous releases, the addtodate function supported modifying a date number by a specified number of years, months, or days. In this release, you can also modify the date by a specified number of hours, minutes, seconds, or milliseconds.

Add 2 hours, 45 minutes, and 17 seconds to the current time:

d1 = now;
datestr(d1)
ans =
   12-Jun-2008 16:15:38

d2 = addtodate(d1, 2, 'hour');
d2 = addtodate(d2, 45, 'minute');
d2 = addtodate(d2, 17, 'second');
d2 = addtodate(d2, 3000, 'millisecond');

datestr(d2)
ans =
   12-Jun-2008 19:00:58

See the function reference page for addtodate for more information.

Querying Options Added to pause

There are new syntaxes for the pause function:

See the function reference page for pause for more information.

File Selection Restriction in Import Wizard

This release introduces a change in how you select the source to import using the Import Wizard. In previous releases, you could select and view the contents of any number of files within the wizard before choosing the one to import. As of this release, if you need to import from a different source (a specific file or the system clipboard) than the one you had originally selected, you must exit and restart the Import Wizard. This change gives the Import Wizard increased flexibility in handling different types of files, removes redundancy in the import process, and also removes a potential source of unexpected behavior from the product.

Compatibility Considerations

The user interface to the Import Wizard is very much the same as in previous versions of MATLAB. However, you should take note of the following changes:

Function Handle Array Warning Is Now An Error

The only way to make an array of function handles is to use a cell array. Attempting to create any other type of array of function handles is invalid. For the past several releases, MATLAB has issued a warning if you should attempt to put function handles into any type of array other than a cell array. As of this release, MATLAB throws an error instead of a warning when this is attempted.

Replace

A = [@sin @cos @tan];
??? Error using ==> horzcat
Nonscalar arrays of function handles are not allowed; use cell arrays instead.

with

A = {@sin @cos @tan};

Compatibility Considerations

If any of your program code attempts to create a regular array of function handles, this code will now generate an error.

Two Types of issorted Warnings Are Now Errors

In previous versions, the issorted function generated a warning for the following two cases:

Using issorted on a Complex Integer

In this case, a statement such as the following

issorted(int8(complex(1,2)))

now issues the error message

??? Error using ==> issorted
ISSORTED on complex inputs with integer class is obsolete.
Please use ISSORTED(DOUBLE(X)) or ISSORTED(SINGLE(X)) instead.

Using issorted on an N-D Array

In this case, a statement such as

issorted(ones(3,3,3),'rows')

now issues the error message

??? Error using ==> issorted
X must be a 2-D matrix.

Compatibility Considerations

If any of your program code attempts to use either of these types of statements, this code will now generate an error.

Possible Conflict with New Keyword: SPMD

This release introduces a new keyword, spmd, that, although used solely by the Parallel Computing Toolbox (PCT), may cause conflicts with MATLAB users as well. See spmd Construct in the PCT release notes for more information on this keyword.

Compatibility Considerations

Because spmd is a new keyword, it will conflict with any user-defined functions or variables of the same name. If you have any code with functions or variables named spmd, you must rename them.

Do Not Create MEX-Files with DLL File Extensions

In the future, on 32-bit Windows® systems, MATLAB will not support MEX-files with a .dll file extension. See release note Do Not Use DLL File Extensions for MEX-Files for information on how this might affect you.

isequal Is Now Called Explicitly for Contained Objects

When you pass two MATLAB objects to isequal, MATLAB dispatches to the isequal method of the dominant object (see Object Precedence in Expressions Using Operators). If the dominant object does not overload isequal, then MATLAB uses the built-in version.

Compatibility Considerations

What is different with this release, is that MATLAB now calls isequal explicitly for each contained object. This means that, if any contained object overloads isequal, MATLAB calls the overloaded version for that object.

Previously, MATLAB compared contained objects using the built-in isequal functionality without regard to any special behavior programmed into overloaded isequal methods. The effect of this change is that, for objects that contain other objects and those contained objects overload isequal, the overloaded behavior establishes the basis with which MATLAB determines equality for those contained objects.

Indexed Assignment with Objects of the Form p(:) = o Now Consistent with MATLAB Language

The behavior of indexed assignment with MATLAB objects is consistent with the behavior of all MATLAB intrinsic types and V5 MATLAB objects. For example, attempting the following assignment, where d does not previously exist, gives an error:

>> d(:) = 5;
???  In an assignment  A(:) = B, the number of elements in A and B
must be the same.

MATLAB objects behave in the same way:

ts_obj = timeseries;
t(:) = ts_obj;
???  In an assignment  A(:) = B, the number of elements in A and B
must be the same.

Compatibility Considerations

In MATLAB Version 7.6 Release 2008a, indexed assignment of the form p(:) = object did not result in an error.

fopen No Longer Supports VAXD, VAXG, and Cray Machine Formats

Calls to fopen with any of the following values for machine format return an error:

Compatibility Considerations

In previous releases, calls to fopen with machine format values associated with VAXD, VAXG, and Cray did not result in an error.

To read files in VAXD and VAXG formats, consider the workaround available on the MATLAB Central File Exchange, file ID #22675.

  


Recommended Products

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

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