Programming, MATLAB Version 7.4 (R2007a)

New features and changes introduced in this version are:

New Functions

New Functions in this release are

FunctionDescription
assertGenerates an error when a specified condition is violated. Displays either the default error message or one that you have written.
ismacReturns true if you are currently running one of the Mac OS X versions of MATLAB.
verLessThanCompares the specified version number and toolbox name with the version of that same toolbox that is currently running. Use verLessThan in your functions when you want to write code that can run across multiple versions of MATLAB.

Multithreading with MATLAB

You can improve the performance of MATLAB on multicore or multiprocessor systems by taking advantage of the multithreaded computational capabilities available in MATLAB in this release. See the following release note under Desktop Tools and Development Environment for more information: Multithreaded Computation Support Added; Enable Via New Preference

Parse Inputs with Consistently Implemented Mechanism

The new inputParser class provides a consistent mechanism for parsing and validating input arguments in the M-file functions you write. Using inputParser methods in the body of your function, you build a schema that represents each valid input argument to the function. In the schema, you can specify whether arguments are required or optional, and if they are to be passed as single values or as parameter-value pairs. The schema also provides a means of validating each incoming argument. The properties of the inputParser class give you additional information about arguments that are passed to the function.

For more information, see Parsing Inputs with inputParser in the MATLAB Programming documentation.

textscan Returns Like Values in Same Cell Array

In previous versions of MATLAB, the textscan function always returned each output value in a separate cell array, even if those values were of the same data type. In this release, if you call textscan with the new CollectOutput switch, MATLAB returns all consecutive data that is of the same type in the same cell array. This can save you the extra task of sorting through the output and merging like data types together in your own code.

For more information, see the textscan function reference page.

Numbered Arguments for Formatted String Functions

Using numbered argument specification with MATLAB functions that employ format specifiers such as %d or %s (e.g., sprintf, error), you can pass the numeric and character string values that correspond to these format specifiers in a varying order. This can be useful when translating format strings in a different sentence structure.

In addition to identifying the values, you can also use numbered arguments to specify the field width and precision of the format specifiers. In the following example, the first format specifier in the sprintf command is %1$*4$f (quite different from the usual %f specifier). The 1$ tells MATLAB that the value that is to replace this format specifier is in the first argument following the format string; that is, 123.45678. The *4$ indicates that the field width for this specifier is being passed in the fourth argument following the format string: 15.

In the second and third arguments (%2$.*5$f and %3$*6$.*7$f), the symbols 2$ and 3$ represent the values, *5$ and *7$ represent precisions, and *6$ represents field width:

sprintf('%1$*4$f   %2$.*5$f   %3$*6$.*7$f', ...
123.45678, 16.42837, pi, 15, 3, 6, 4)

ans =
     123.456780   16.428   3.1416

For more information, see Formatting Strings in the MATLAB Programming documentation.

The dir Function Returns Additional datenum Field

The dir function now returns the date the file or directory was last modified in two formats: string and numeric. The numeric date value is not specific to any particular locale, and thus is compatible for international use:

fileinfo = dir('myfile.txt')

fileinfo = 
       name: 'myfile.txt'
       date: '16-Mar-2006 13:34:01'
      bytes: 251
      isdir: 0
    datenum: 7.3275e+005

This new output is also returned when running dir on an FTP server.

Using whos -file on Objects with Overloaded size or class Methods

MATLAB is unable to determine the true size of an object stored in a MAT-file if the class of this object overloads the MATLAB size function. Likewise, MATLAB cannot determine the true class name of an object if it overloads the MATLAB class function. For these reasons, in previous versions of MATLAB, the command whos -file does not return or display object size and class accurately if the class of that object overloads these methods, but instead always returns 1x1 for the size and a default name for the class.

In this release, whos -file returns the empty matrix ([]) or displays a hyphen (-) for objects that overload size, and returns and displays unknown for objects that overload class.

Compatibility Considerations

If you use whos -file on objects in any of your programs, and if any of these objects overloads the size function, then you need to be aware that MATLAB now returns [] instead of a 2–element vector of ones in the size field of the output structure.

mat2str Returns Correct Output for Strings

The documentation for the mat2str function states that the str output of this function "is suitable for input to the eval function such that eval(str) produces the original matrix to within 15 digits of precision." The behavior of mat2str when given a character array as input, however, did not abide by this rule. This inconsistency has been fixed in this release.

In MATLAB Version 7.3, the eval command below generated an error.

s = mat2str('MATLAB')
s =
   'MATLAB'

eval(s)
ans =
   MATLAB

Compatibility Considerations

You might have to modify M-file programs that expect the previous behavior from mat2str.

Warning Generated by try-catch

To accommodate future changes in the MATLAB error-handling capabilities, there is a new restriction to the syntax of the try-catch block. When the first MATLAB statement that follows the try keyword consists of just a single term (e.g., A as opposed to A+B) occurring on the same line as the try, then that statement and the try keyword should be separated by a comma. For example, the line

try A

should be written as either

try, A

or on two lines as

try
   A

This affects only single-term statements. For example, the following statement continues to be valid:

try A+B

The same holds true for the catch keyword and a single-term statement following the keyword on the same line. A valid try-catch statement of this type should be composed as follows:

try, A, catch, B, end

If you omit the commas following try and/or catch, your code will continue to operate correctly. However, MATLAB will issue a warning:

try statements, catch statements, end

Warning: This try-catch syntax will continue to work in R2007a, 
but may be illegal or may mean something different in future 
releases of MATLAB.

As with previous releases, the recommended syntax for a try-catch block is as follows:

try
   try_statements
catch
   catch_statements
end

Compatibility Considerations

Your M-file programs may generate the warning shown above if the correct syntax for try and catch is not used.

save -regexp Saves to Correct Filename

In previous releases, the following command mistook the -regexp argument ([ab] in the case shown below) to be the name of the file to save to:

save -regexp [ab]

In this release, the filename is correctly understood to be the default save filename, matlab.mat, and any arguments that follow the -regexp flag and precede the next flag are interpreted as patterns to be matched.

Functions Not Callable If in Directory Under Class Directory

M-files placed in a directory that is one or more levels beneath a MATLAB class directory are not callable from that same directory. A MATLAB class directory contains methods of a class and has a filename that begins with the @ character.

In the following example, function myfun1 is not callable if the current working directory is set to dir1. The same holds true for myfun2 if the current working directory is set to dir2.

\home\matlab\@myobj\dir1\myfun1.m
\home\matlab\@myobj\dir1\dir2\myfun2.m

This behavior existed in the R2006b release, as well as in this release.

Compatibility Considerations

You will no longer be able to call a file that is one or more levels beneath a MATLAB class directory if your current working directory is set to that same directory.

Improved Performance on Certain Platforms and Operations

As of release R2006b, MATLAB offers improved performance in the following areas:

Technique to Conserve Memory on Windows Vista

To conserve memory on machines running Windows Vista, you can reduce the amount of virtual memory space reserved by the operating system by using the command:

BCDEdit /set increaseuserva 3072

More documentation on this option can be found at the following URL:

http://msdn2.microsoft.com/en-us/library/aa906211.aspx

ispuma Function Deprecated

Because MATLAB no longer supports OSX 10.1, the ispuma function always returns false in this release, and also displays a warning message that the function is now deprecated. Support for ispuma will be removed in a future release of MATLAB.

Compatibility Considerations

It is recommended that you remove calls to ispuma from your M-file functions.

  


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