Products & Services Solutions Academia Support User Community Company

Learn more about MATLAB   

Programming, MATLAB Version 7.9 (R2009b)

New features and changes introduced in this version are

Ignore Selected Arguments on Function Calls

This version of MATLAB introduces a new usage for the tilde (~) operator. As in earlier releases, tilde signifies a logical NOT. In the 9b release, you can also use the tilde operator to specify unused outputs in a function call, or unused inputs in a function definition. See Ignoring Selected Outputs or Input Arguments in the Programming Fundamentals documentation for more information on this feature.

Replacing Output Variables with Tilde

This feature enables you to replace this type of function call:

[val1, ignoreThisOutput, val3] = myTestFun;

with the following:

[val1, ~, val3] = myTestFun;

MATLAB ignores any values returned by a function that have a corresponding tilde in the output list. This new syntax can help you avoid confusion in your program code and unnecessary clutter in your workspace. It also avoids wasting memory to store unused outputs returned from the called function.

Replacing Input Arguments with Tilde

You can also use the tilde operator to specify unused inputs when you are creating a function. You can replace this type of function definition:

function myTestFun(arg1, ignoreThisInput, arg3)

with the following

function myTestFun(arg1, ~, arg)

Whenever this function is called, MATLAB ignores any inputs passed to the function that have a tilde in the corresponding position in the input argument list. You are likely to find the tilde operator most useful when writing callback functions and subclass methods that must match a predefined function interface.

Internal Packages Make Reserved Functions Easy to Identify

The MathWorks® reserves the use of packages named internal for utility functions used by internal MATLAB code. Functions that belong to an internal package are intended for The MathWorks use only. Using functions that belong to an internal package is strongly discouraged. These functions are not guaranteed to work in a consistent manner from one release to the next. In fact, any of these functions and classes may be removed from the MATLAB software in any subsequent release without notice and without documentation in the product release notes.

See Internal Utility Functions in the Programming Fundamentals documentation for more information.

Use of lasterror, lasterr, rethrow(errStruct) Not Recommended

In version 7.5, The MathWorks introduced a new class called MException for use in error handling. Prior to this change, the lasterr and, more recently, lasterror functions kept track of only the one most recently thrown error. The state of any errors thrown before that was overwritten by newer errors. Also, this error state was globally accessible, which means that it could be unintentionally modified or destroyed either during an interactive session or by another function.

When using the newer, object-based error mechanism, every error generated by a MATLAB function stores information about what caused the error in a separate MException object. This enables MATLAB to store information about multiple errors, adds the capacity to store new fields of information including links to related errors, and also resolves the problem of being globally accessible.

The MathWorks now discourages the use of the lasterr and lasterror functions because the information they return is global and thus has the potential to be corrupted. You should replace the use of these two functions with the new style of try-catch statement that captures an MException object to represent the error. When entering commands at the MATLAB command line, you can also use the static method Mexception.last to retrieve information on the most recent error. For more information on this method of error handling, see The MException Class.

This change also affects which form of the rethrow function to use when reissuing an exception. The original rethrow function, in use since before version 7.5, accepts only a structure as input. Because this structure is typically obtained using the lasterror function, this form of rethrow should be avoided. The later form of rethrow(MException), introduced in version 7.5, accepts an MException object as input, and is the recommended form.

Compatibility Considerations

It is strongly recommended that you discontinue the use of lasterror and lasterr, and that you replace the use of these functions in your program code with the MException-based style of error handling described above.

Use of maxNumCompThreads No Longer Recommended

Invoking the function maxNumCompThreads now returns the following warning:

Warning: maxNumCompThreads will be removed in a future release. 
Please remove any instances of this function from your code.

maxNumCompThreads continues to operate the same in this release of MATLAB. However, the function will be discontinued in a future release of the product.

Compatibility Considerations

It is recommended that you discontinue the use of maxNumCompThreads. However, if you do have any program code that invokes this function, you should make sure that such programs are not affected by this new warning.

Excel Worksheet Selection in the Import Wizard

In previous releases, the Import Wizard imported only the first populated worksheet in an Excel file. The Import Wizard now allows you to specify the worksheet to import. To start the Import Wizard, use one of the following methods:

Motion JPEG 2000 Files Supported by mmreader

mmreader now imports Motion JPEG 2000 (.mj2) files on Windows, Macintosh, and Linux platforms.

Compatibility Considerations

Because mmreader imports Motion JPEG 2000 files, the function mmreader.isPlatformSupported always returns true on Windows, Macintosh, and Linux platforms. For a list of file formats that mmreader supports, and the requirements to read these formats on each platform, see the mmreader reference page.

Minimum Sample Rate for audioplayer

If you specify a sample rate less than 80 samples per second, audioplayer generates an error with the following ID:

MATLAB:audioplayer:positivesamplerate

Compatibility Considerations

In previous releases, the error ID on Windows platforms for low sample rates was:

MATLAB:audioplayer:negativesamplerate

Change any references to this identifier to:

MATLAB:audioplayer:positivesamplerate

Documentation Changes: File I/O and Data Import and Export

The function category "File I/O" is renamed "Data Import and Export." It appears immediately below the category "Desktop Tools and Development Environment."

In the MATLAB User Guide, Data Import and Export content previously appeared in the Programming Fundamentals documentation. The User Guide now includes a stand-alone topic for Data Import and Export.

Object Array Property Indexing

Object array indexing operations on properties now return an error for improper array references. Before MATLAB 7.9, an expression such as:

obj.Prop(n) % for non-scalar obj is invalid if Prop is a property

did not return an error. MATLAB 7.9, you can reference or assign properties from scalar objects only by entering:

obj(int).Prop(n)

where int is a positive integer.

Equality of Objects Using isequal Now Ignores Numeric Class

Before MATLAB 7.9, an expression such as:

isequal(a,b)

returned false in cases where a and b are objects of the same class that have properties set to numeric values which are mathematically equivalent, but of different classes (for example, double and single),

The behavior of isequal in MATLAB 7.9 is consistent with the documented behavior (see isequal). isequal does not consider class when comparing numeric values.

Class Defining Private/Abstract Property Now Errors

MATLAB 7.9 returns an error when it loads a class that defines a property as both Abstract and Private.

Subclasses of Built-in Classes and numel

Before MATLAB 7.9, the numel function did not return the same results for built-in classes and subclasses of built-in classes. In MATLAB 7.9, the behavior of numel is consistent with built-in classes and subclasses of built-in classes. See Understanding size and numel for a discussion of the current behavior.

Array Expansion with Indexed Assignment

Before MATLAB 7.9, initializing a handle object array by specifying the last element in the array to create it:

obj(10) = MyClass;

resulted in the same handle being assigned from the second to the penultimate elements of the array. With MATLAB 7.9, all elements in the handle object array have unique handles. See Creating Object Arrays for more information on the current behavior.

New Tiff Object Enables Writing of Tiled Data and Broader Metadata Support

Using the new Tiff object, you can now write portions of a TIFF file and update the values of individual metadata tags in an image. MATLAB has long offered the capability of reading and writing TIFF files, using the imread and imwrite functions. However, if you wanted to update any part of the image, you had to write the entire image to the file. Similarly, if you just wanted to update a tag, you had to write the entire image. By providing access to functions in the LibTIFF library, the Tiff object offers more flexibility in creating and editing TIFF images. You can write data to specific tiles in an image and update individual tags in a file, without having to write the entire image.

Ambiguity Error Now Reported

Due to a bug, versions of MATLAB prior to Version 7.9 did not report an error in functions such as the following, even though it cannot be determined in the last line whether U is a variable or a function:

function r = testMfile1(A) 
A = 1; 
eval('U = 1;'); 
r = A(logical(end), U(end)); 

However, if you replace the last line with

r = A(U(end)); 

MATLAB reports an ambiguity error and has done so since Version 7.0. Starting in Version 7.9, MATLAB reports an ambiguity error for either statement.

Compatibility Considerations

In certain circumstances, it is possible that you will see ambiguity errors generated in code that did not report this error in previous releases. If you do get such an error, examine your code and resolve the ambiguous statements.

  


Recommended Products

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

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