| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → MATLAB |
| Contents | Index |
| Learn more about MATLAB |
Caution If you have saved data to a MAT-file using MATLAB Release 14 Beta 2, please read MAT-Files Generated By Release 14 Beta2 Must Be Reformatted. |
This version introduces the following new features and changes:
MATLAB Stores Character Data As Unicode; Making Release 14 MAT-files Readable in Earlier Versions
Additional Bytes Reserved in MAT-File Header; Do Not Write To Reserved Space
Case-Sensitivity in Function and Directory Names; Can Affect Which Function MATLAB Selects
Differences Between Built-Ins and M-Functions Removed; Can Affect Which Function MATLAB Selects
Prior releases of MATLAB represented character data in memory using a system default character encoding scheme that was padded out to 16-bits. This was the case both in memory and in MAT-files. If this data needed to be accessible to multiple users, each user's system had to use the same character encoding scheme. For those users whose default encoding scheme differed, the exchange of character-oriented information was not possible.
In Release 14, this limitation is removed by adopting the Unicode character encoding scheme in mxArrays and their storage in MAT-files. For more information regarding Unicode, consult the Unicode Consortium web site at http://www.unicode.org.
For more information on saving character data using Unicode encoding, see Writing Character Data in the External Interfaces documentation. For information on the internal formatting of MAT-files, see the "MAT-File Format" document in the MATLAB documentation available in PDF format
Release 14 MATLAB writes character and figure data to MAT-files using Unicode character encoding by default. This is now the default encoding used by MATLAB when writing to MAT-files with the save and hgsave functions or with the MAT-file external interface functions.
Unicode encoded MAT-files are not readable by earlier versions of MATLAB. Thus, if you save data to a MAT-file using MATLAB Release 14, and you intend to load this MAT-file into an earlier release of MATLAB, you must override the default encoding during the save, as explained in this section.
You can override the default encoding by using the -v6 switch with save and hgsave:
save filename -v6 hgsave filename -v6
or, when saving with MAT functions, by setting the mode to "wL" on the matOpen operation:
matOpen(filename, "wL");
Any MAT-files that you created with Release 14 Beta 2 were written using an internal format that is no longer supported by MATLAB.
If you need to import data from these files using any release besides Release 14 Beta 2, you must first regenerate the files as described in this section. You cannot read these files using other releases of MATLAB 7.0, and attempting to read them with MATLAB 6.5 or 6.5.1 will corrupt memory.
There are two ways in which you can regenerate your MAT-file:
If you want to use the MAT-file with earlier versions of MATLAB, regenerate the file using the local character set for your system. To do this, run MATLAB R14 prerelease or MATLAB R14 Beta 2, load the MAT-file, and rewrite the file using the command
save filename -v6
If you want to use the MAT-file with R14 LCS or later, regenerate the file using Unicode character encoding. To do this, run MATLAB R14 prerelease, load the MAT-file, and rewrite it using the following command that uses the -unicode default.
save filename
Caution The final R14 release of MATLAB does not allow you to import a MAT-file written with Release 14 Beta 2. You will get an error if you attempt to do this. To use a Beta 2 MAT-file with Release 14, you must first reformat the file with MATLAB R14 prerelease as described above. |
If you no longer have access to Release 14 Beta2 or the R14 prerelease, then you must regenerate the data and save it again.
Unicode-based character classification APIs are now provided in MATLAB. The new character classification functions work with any locale or language and resolve all locale-specific issues that existed in prior releases.
Character data rendering has been improved for Linux operating systems that are configured with a UTF-8 default character set.
In previous releases of MATLAB, the last 4 bytes of the 128-byte MAT-file header were reserved for use by the MathWorks. In Release 14, the last 12 bytes of this header are reserved. See the PDF file "MAT-File Format" for more information.
If you have programs that write to any of the last 12 bytes of the MAT-file header, or if they rely on the state of the 8 additional header bytes that are reserved as of this release, you will probably need to change your code. These bytes are now used by MATLAB. If your code writes to these bytes, MATLAB is likely to overwrite this data. If your code reads these bytes, they might not be in the same state as they were in previous releases of MATLAB.
The save function compresses your workspace variables as they are saved to a MAT-file. When writing a MAT-file that you will need to load using an earlier version of MATLAB, be sure to use the save -v6 command. When you use the -v6 switch, MATLAB saves the data without compression and without Unicode character encoding. This makes the resulting file compatible with MATLAB Version 6 and earlier.
You can also compress data when using MAT-file interface library functions (matPut*) to write to a MAT-file by opening the file with the command matOpen wz. See the section Data Compression in the MATLAB Data Import and Export documentation for more information on this feature.
Two new syntaxes for the save function enable you to save individual fields of a structure to a file. See the function reference for save for more information.
To save all fields of the scalar structure s as individual variables within the file, myfile.mat, use
save('myfile', '-struct', 's')To save as individual variables only those structure fields specified (s.f1, s.f2, ...), use
save('myfile', '-struct', 's', 'f1', 'f2', ...)Prior to this release, filenames for MATLAB functions and Simulink models, (M, P, MEX, DLL, and MDL files) and also directory names were interpreted somewhat differently by MATLAB with regards to case sensitivity, depending upon which platform you were running on. Specifically, earlier versions of MATLAB handled these names with case sensitivity on UNIX, but without case sensitivity on Windows.
This release addresses the issue of case sensitivity in an effort to make MATLAB consistent across all supported platforms. By removing these differences, we hope to make it easier for MATLAB users to write platform independent code.
There are several rules regarding case sensitivity that were already consistent across all platforms in MATLAB 6, and remain in effect on all platforms in MATLAB 7. MATLAB interprets each of the following with case sensitivity on both Windows and UNIX:
Function names that correspond to MATLAB built-ins
M-file subfunction names
The names of functions imported from another language environment, such as Java or COM
UNIX. On all UNIX platforms, including the new implementation on MacIntosh, all function, model, and directory names were case sensitive and required an exact match. This rule remains true for UNIX systems in MATLAB 7.
Windows. On Windows platforms, MATLAB 6 obeys the following rules. These rules are changing in MATLAB 7:
Function and model names were not case sensitive.
Directory names, including MATLAB class directory names (e.g., @MyClass) and private directory names (e.g., prIVAte) were not case sensitive.
MATLAB 7 removes the platform specific behaviors by adopting its UNIX case sensitivity rules on Windows systems. MATLAB running on Windows now gives preference to an exact (case sensitive) name match, but falls back to an inexact (case insensitive) match when no exact match can be found.
There are four main conditions under which MATLAB 7 interprets directory or function names differently in regards to case sensitivity:
In any of these cases, each described below, there is a potential for MATLAB to select a file other than the one you had intended.
Whenever MATLAB 7 detects a potential naming conflict related to case sensitivity, it issues a warning. If you get one of these warnings when running a MATLAB program, you may want to modify the related code to eliminate the warning, or you may wish to simply disable the warning. To disable this type of warning, see Turning Off Warnings Caused by Case Mismatch.
Two Files of the Same Name. Consider the situation in which there are two or more directories on the MATLAB path that contain a function or model file of the same name. The names of these M-files differ only in letter case:
H:\released\myTestFun.m K:\under_test\mytestfun.m
Of these two directories, H:\released is closer to the beginning of the MATLAB path and, thus, has priority over the other:
path = H:\released; K:\under_test; ...
On Windows Platforms —
In MATLAB 6, executing the function mytestfun invokes H:\released\myTestFun.m.
In MATLAB 7, executing the function mytestfun invokes K:\under_test\mytestfun.m and also displays the following warning:
Function call mytestfun invokes K:\under_test\mytestfun.m however, function H:\released\myTestFun.m, that differs only in case, precedes it on the path.
On UNIX Platforms —
MATLAB 7 does the same as on Windows, except that the warning message is disabled by default.
Two Method Files of the Same Name. In this case, there are two M-files of the same name that implement methods of a MATLAB base class and one of its subclasses:
@baseclass/my_method.m @subclass/My_Method.m
On Windows Platforms —
In MATLAB 6, the command my_method(subclass) invokes @subclass/My_Method.
In MATLAB 7, the same command invokes @baseclass/my_method because it is an exact match.
On UNIX Platforms —
MATLAB 7 does the same as on Windows.
One File with an Inexact Match. Another situation that MATLAB now handles differently involves just one function or model file that matches the function being called:
H:\released\myTestFun.m
However, the name of this M-file does not match the called function (mytestfun) in letter case.
On Windows Platforms —
In MATLAB 6, calling the function mytestfun invokes H:\released\myTestFun.m.
In MATLAB 7, calling the function mytestfun invokes the same M-file but also displays the following warning:
Function call mytestfun invokes inexact match H:\released\myTestFun.m.
On UNIX Platforms —
In MATLAB 6, calling the function mytestfun results in an error.
In MATLAB 7, calling mytestfun invokes H:\released/myTestFun.m and generates the following warning:
Function call mytestfun invokes inexact match H:/released/myTestFun.m.
Private Directory Names. Private functions must reside in a directory named private that is one level down from the directory of any calling function. As of this release, the directory name private is case sensitive on Windows as it has always been on UNIX.
On Windows Platforms —
In MATLAB 6, calling function myprivfun in an environment where only a subdirectory named \PriVAte contains the M-file myprivfun.m invokes \PriVAte\myprivfun without displaying a warning.
MATLAB 7 does the same as MATLAB 6, except that it also displays the following warning:
Wrong case spelling of 'private' as a directory name in \released\PriVate\myprivfun.m.
On UNIX Platforms —
In MATLAB 6, calling function myprivfun in an environment where only a subdirectory named \PriVAte contains the M-file myprivfun.m results in an error.
In MATLAB 7, calling myprivfun in this same environment invokes /PrivATe/myprivfun and also displays the following warning:
Wrong case spelling of 'private' as a directory name in /released/PriVate/myprivfun.m.
You can disable most warnings caused by case mismatch with the following command:
warning off MATLAB:dispatcher:InexactMatch
To disable this warning for all of your MATLAB sessions, add this command to your startup.m or matlabrc.m file.
If you continue to get case sensitivity warnings after entering this command, you can disable a wider range of warnings with the following command:
warning off ... MATLAB:dispatcher:CaseInsensitiveFunctionPrecedesExactMatch
Note This latter warning alerts you when, for case sensitivity reasons, MATLAB may have selected a different M-file from the one you had intended to run. It is recommended that you leave this warning enabled. |
MATLAB implements many of its core functions as built-ins. In previous releases of MATLAB, there have been several significant differences between the way MATLAB handles built-in and M-file functions. As of this release, MATLAB handles both types of functions the same. This change affects the following:
MATLAB now dispatches both built-in and M-file functions according to the same precedence rules, (see Function Precedence Order in the MATLAB Programming documentation). In previous releases, subfunctions, private functions, and class constructor functions took precedence over M-functions of the same name, but not over built-ins. In this release, built-in functions follow the same rules given to M-functions, and thus are lower in precedence than the three function types named above.
This change addresses a potential problem in that changes to the internal implementation of MATLAB functions could potentially affect the operation of your own M-code. For example, if a new version of MATLAB were to change an internal function from being M-based to being built-in, the function in the new version would now be subject to different precedence rules. If one of your M-code modules had a subfunction with the same name as this function (now obeying the built-in rules), then this subfunction would never be called.
This release resolves this potential conflict by using the same precedence rules for both M-functions and built-ins.
Compatibility Considerations. If any of your programs have subfunctions, private functions, or class constructor functions that have the same name as a built-in function that has the same function scope, MATLAB now gives precedence to the subfunction, private function, or constructor rather than the built-in. If this is not corrected, you may find instances where your program calls a function other than the one you had intended. You can avoid such problems by renaming any functions that may conflict with a MATLAB built-in function.
The MATLAB functions function returns information about a function handle such as the function name, type, and filename. In previous releases, functions returned the filename for a built-in function as the string
'MATLAB built-in function'
In this release, MATLAB associates each built-in function with a placeholder file that has a .bi extension (for example, reshape.bi for the built-in reshape function).
The which function now displays the pathname for built-in functions, as well as for overloaded functions when only the overloaded functions are available.
The following warning was added to identify the case when you first use a name as a function and later use it as a variable:
Warning: File: D:\Work\MATLAB XL\theworks\my_yprime.m Line: 17 Column: 1 Variable 'getdata' has been previously used as a function name. (Type "warning off MATLAB:mir_warning_variable_used_as_function: to suppress this warning.)
For example, this code generates such a warning:
X = i; % Calls the function i() to get sqrt(-1) for i = 1:10 % uses i as a variable. This produces the warning. ... end
In Release 13 and earlier, the evalin function evaluated its input in the specified workspace, but not the workspace's corresponding dispatching context. Hence, running the following example used to succeed, calling the subfunction MySubfun but using the value of x from the base workspace:
function demo
evalin('base', 'MySubfun(x)')
function MySubfun(in)
disp(in)When you call evalin in Release 14, MATLAB tries to find a function named MySubfun that is accessible in the base workspace, i.e. at the command prompt. Since MySubfun is a subfunction and therefore not in scope at the command prompt, MATLAB errors, reporting that MySubfun is undefined.
There are two ways to change your existing code to work with this new behavior. First, if your code only needs to get the value of the subfunction's inputs from the base workspace (as demo.m does above), and does not care what context MySubfun is run in, then you can change your code to use evalin only to get the values of the inputs from the base workspace, like this:
function demo_workaround1
MySubfun(evalin('base', 'x'))
function MySubfun(in)
disp(in) If, however, it is important that the subfunction itself be run in the context of the base workspace, you can place a function handle to the subfunction in the base workspace and then evaluate that:
function demo_workaround2
assignin('base', 'MySubfunHandle', @MySubfun);
evalin('base', 'MySubfunHandle(x)')
function MySubfun(in)
disp(in) You can also substitute 'caller' for 'base' in the workaround code if your original code uses evalin('caller', ...).
These functions are new in this release.
Function | Description |
|---|---|
Modify a particular field of a date number | |
Construct valid variable name from string | |
Return largest possible integer value | |
Return smallest possible integer value | |
Control state of integer warnings | |
Detect floating-point arrays | |
Detect whether an array has integer data type | |
Determine if item is a scalar | |
Determine the content of each element of a string | |
Determine if item is a vector | |
Get information about multimedia file | |
Set option to move deleted files to recycle folder | |
Restore default search path | |
Remove leading and trailing whitespace from string | |
Read data from text file, convert and write to cell array | |
Write matrix to a Microsoft Excel spreadsheet |
Anonymous functions give you a quick means of creating simple functions without having to create M-files each time. You can construct an anonymous function either at the MATLAB command line or from within another function or script.
Refer to Anonymous Functions in the MATLAB Programming documentation for more complete coverage of this topic. For more information on anonymous functions, open the M-file anondemo.m in the MATLAB Editor by typing
edit anondemo
The syntax for creating an anonymous function from an expression is
fhandle = @(arglist) expr
where arglist is a comma-separated list of input variables, and expr is any valid MATLAB expression. The constructor returns a function handle, fhandle, that is mapped to this new function. Creating a function handle for an anonymous function gives you a means of invoking the function. It is also useful when you want to pass your anonymous function in a call to some other function.
Note Function handles not only provide access to anonymous functions. You can create a function handle to any MATLAB function. The constructor uses a different syntax: fhandle = @functionname (e.g., fhandle = @sin). To find out more about function handles, see Function Handles in the MATLAB Programming documentation. |
You can use the function handle for an anonymous function in the same way as any other MATLAB function handle.
To create a simple function sqr to calculate the square of a number, use
sqr = @(x) x.^2;
To execute the function, type the name of the function handle, followed by any input arguments enclosed in parentheses:
a = sqr(5) a = 25
Since sqr is a function handle, you can pass it to other functions. The code shown here passes the function handle for anonymous function sqr to the MATLAB quad function to compute its integral from zero to one:
quad(sqr, 0, 1) ans = 0.3333
To store multiple anonymous functions in an array, use a cell array. See Arrays of Anonymous Functions in the MATLAB Programming documentation.
You can find more examples of how to use anonymous functions in MATLAB under Examples of Anonymous Functions.
You can now define one or more functions within another function in MATLAB. These inner functions are said to be nested within the function that contains them. You can also nest functions within other nested functions.
Refer to Nested Functions in the MATLAB Programming documentation for more complete coverage of this topic. For more information on nested functions, open the M-file nesteddemo.m in the MATLAB Editor by typing
edit nesteddemo
To write a nested function, simply define one function within the body of another function in an M-file. Like any M-file function, a nested function contains any or all of the usual function components. In addition, you must always terminate a nested function with an end statement:
function x = A(p1, p2) ... function y = B(p3) ... end ... end
Two characteristics unique to nested functions are
A nested function has access to the workspaces of all functions inside of which it is nested. A variable that has a value assigned to it by the primary function can be read or overwritten by a function nested at any level within the primary. Similarly, a variable that is assigned in a nested function can be read or overwritten by any of the functions containing that function.
When you construct a function handle for a nested function, the handle not only stores the information needed to access the nested function; it also stores the values of all variables shared between the nested function and those functions that contain it. This means that these variables persist in memory between calls made by means of the function handle.
You can find examples of how to use nested functions in MATLAB under Examples of Nested Functions.
You can now invoke a private function from a script, provided that the script is called from another M-file function, and that the private function being called by the script is within the scope of this M-file function.
You can now call functions by means of their related function handles using standard calling syntax rather than having to use feval. When calling a function using its handle, specify the function handle name followed by any input arguments enclosed in parentheses.
For example, if the handle to a function was stored in variable h, you would call the function as if the handle h were a function name:
h(arg1, arg2, ...)
For the parabola function shown here, construct a function handle h and call the parabola function by means of the handle:
function y = parabola(a, b, c, x) y = a*x.^2 + b*x + c; parabHandle = @parabola; parabHandle(1.3, .2, 30, 25)
When calling functions that take no input arguments, you must use empty parentheses after the function handle:
parabHandle()
Using feval for the purpose of invoking functions via function handle is no longer necessary and is, in fact, slower. However, for purposes of backward compatibility, the use of feval to evaluate function handles is still supported in this release.
Parenthesis notation on a nonscalar function handle means subscripting, just as in Release 13, while the same notation on scalar function handles means function call, as described above. Incompatibility can arise only if you construct a scalar array of function handles and actually index it, necessarily with an index of 1.
Previous releases of MATLAB supported arrays of function handles. You created such an array using the [] operator, and indexed into the array with the () operator:
x = [@sin @cos @tan]; plot(feval(x(2), -pi:.01:pi));
In Release 14, MATLAB supports arrays of functions handles using cell arrays. You create and index into a function handle array using the {} operator:
x = {@sin @cos @tan};
plot(x{2}(-pi:.01:pi));For purposes of backward compatibility, standard arrays of function handles are still supported in this release.
When you pass the name of a function to nargin or nargout, MATLAB returns the number of declared inputs or outputs for that function. For example, passing the function name 'normest' to nargin returns 2, (the number of inputs declared in normest.m:
nargin('normest') % normest is an M-function.
ans =
2In this release, you can also use this feature with MATLAB built-in functions. The following use of nargin returned an error in previous versions of MATLAB because norm is implemented as a built-in function. In this release, nargin returns the number of inputs declared by the norm function:
nargin('norm') % norm is a built-in function.
ans =
2The same applies to nargout.
As of Release 14, the function definition line in a function M-file no longer requires commas separating output variables. This now makes the function definition syntax the same as the syntax used when calling an M-file function:
function [A B C] = myfun(x, y)
This new syntax is not valid in MATLAB versions earlier than Release 14. When writing an M-file that you expect to run on versions both earlier and later than R14, be sure to separate any output variables in the function definition line with commas:
function [A, B, C] = myfun(x, y)
There are no plans to remove the getfield and setfield functions from the MATLAB language, as stated in the release notes for MATLAB Release 13.
Support for the isglobal function will be removed in a future release of MATLAB. In Release 14, invoking isglobal generates the following warning:
Warning: isglobal is obsolete and will be discontinued. Type "help isglobal" for more details.
To protect yourself from unintentionally deleting any files that you want to keep, use the new recycle function to turn on file recycling. When file recycling is on, MATLAB moves all files that you delete with the delete function to either the recycle bin (on the PC or Macintosh) or a temporary folder (on UNIX). When file recycling is off, any files you delete are actually removed from the system.
You can turn recycling on for all of your MATLAB sessions using the Preferences dialog box. (Select File > Preferences > General.) Under the heading Default behavior of the delete function, select Move files to the Recycle Bin.
The bin2dec function now ignores any space (' ') characters in the input string. Thus, the binary string '010 111' now yields the same result as the string '010111'.
In Release 13, bin2dec interpreted space characters as zeros:
bin2dec('010 111')
ans =
39In this release, bin2dec ignores all space characters:
bin2dec('010 111')
ans =
23In previous versions, a MATLAB session would terminate prematurely when attempting to execute certain P-code files if you had set a debugger breakpoint in the function represented by that file. For example, an attempt to run Guide would terminate your MATLAB session if you had used the dbstop function to set a breakpoint in the corresponding M-file:
dbstop in guide guide
This bug has been fixed in this release enabling you to debug these files successfully.
MATLAB bit functions now work on unsigned integers. Instead of using flints (integer values stored in floating point) to do you bit manipulations, consider using unsigned integers. See Bit Functions Now Work on Unsigned Integers in the MATLAB Mathematics release notes.
The inmem function now returns not only the names of the currently loaded M- and MEX-files, but the path and filename extension for each as well. Use the -completenames option to obtain this additional information:
inmem('-completenames')The section New Nondouble Mathematics Features describes new features affecting the nondouble (single and integer) data types. These changes affect single and integer arithmetic operations, and also conversion of single and double data types to integers.
Most mathematic operations are not supported on logical values.
In many instances, you can access the data in cell arrays and structure fields without using the deal function. Here is an example that reads each of the cells of a cell array into a separate output:
C = {rand(3) ones(3,1) eye(3) zeros(3,1)};Use either of the following to access the cells in C:
[a,b,c,d] = deal(C{:})
[a,b,c,d] = C{:}Here is an example that reads each of the fields of a structure array into a separate output:
A.name = 'Pat'; A.number = 176554; A(2).name = 'Tony'; A(2).number = 901325;
Use either of the following to access the name field:
[name1,name2] = deal(A(:).name) [name1,name2] = A(:).name
This version of MATLAB introduces the following new features in regular expression support:
Multiple Input Strings — You can use any of the MATLAB regular expression functions with cell arrays of strings as well as with single strings. Any or all of the input parameters (the string, expression, or replacement string) can be a cell array of strings.
Selective Outputs — To select what type of data you want the regexp and regexpi to return (string indices or text, token indices or text, or token data by name) use one or more of the six qualifiers for these functions.
Lookaround Operators — Lookahead and lookbehind operators enable you to match a pattern only if it is preceded, or followed, by another pattern.
New Logical Operators — New operators for grouping, inserting comments, and finding alternative match patterns
New Quantifiers — Lazy quantifiers match a minimum number of characters in a string. Possessive quantifiers do not reevaluate parts of the string that have already been evaluated
Element Grouping — Group elements together using either (...) to group and capture, or (?:...) for grouping alone
Named Capture Grouping — Capture characters in a token and assign a name to the token
Conditional Expressions — Process a string in different ways depending on a stated condition
New Character Representations — New symbolic representations such as \e for escape, or \xN for a character of hexadecimal value N, are available in this release.
Default Tokenizing — The regexprep function now tokenizes by default. There is no longer a 'tokenize' option
Refer to Regular Expressions in the MATLAB Programming documentation.
The who, whos, save, load, and clear functions now accept regular expressions as input. This feature enables you to be more selective concerning which variables they operate on.
For example, this statement saves to a MAT-file only those variables with a name that either starts with the letters A or B, or contains ten or more characters:
save('mydata.mat', '-regexp', '^[AB].', '.{10,}');If the workspace contains the following four variables, two of the four meet the requirements of the regular expression:
whos Name Size Bytes Class A_stats 10x5 400 double array X23456789 1x1 12 char array ab 3x1 536 struct array longerVariableName 1x4 8 char array
When you perform the save operation and then check the contents of the MAT-file, you see that the variables with names that either start with A or have at least ten characters were saved:
save('mydata.mat', '-regexp', '^[AB].', '.{10,}');
whos -file mydata.mat
Name Size Bytes Class
A_stats 10x5 400 double array
longerVariableName 1x4 8 char arrayRefer to the reference pages for these functions for more information and examples.
You can now pass a vector of strings in a cell array to any of the MATLAB regular expression functions (regexp, regexpi, and regexprep).
Because this is the preferred method of passing a string vector, MATLAB no longer supports using character matrices for this purpose.
You can now pass a cell array of strings to the strfind function. MATLAB searches each string in the cell array for occurrences of the pattern string, and returns the starting index of each such occurrence.
The statement str = mat2str(A, 'class') creates a string with the name of the class of A included. This option ensures that the result of evaluating str will also contain the class information.
Change the 16-bit integer matrix to a string that includes 'int16'. Next, evaluate this string and verify that you get the same matrix that you started with:
x1 = int16([-300 407 213 418 32 -125]);
A = mat2str(x1, 'class')
A =
int16([-300 407 213 418 32 -125])
x2 = eval(A);
isa(x2, 'int16') && all(x2 == x1)
ans =
1Use the new isstrprop function to see what parts of a string or array of strings are alphabetic, alphanumeric, numeric digits, hexadecimal digits, lowercase, uppercase. white-space characters, punctuation characters, contain control characters, or contain graphic characters.
For example, to test for alphabetic characters in a two-dimensional cell array, use
A = isstrprop({'abc123def';'456ghi789'}, 'alpha')
A =
[1x9 logical]
[1x9 logical]
A{:,:}
ans =
1 1 1 0 0 0 1 1 1
0 0 0 1 1 1 0 0 0You can now use the strtok function on a cell array of strings. When used with a cell array of strings, strtok returns a token output that is also a cell array of strings, each containing a token for its corresponding input string.
See the strtok reference page to see an example of how this works.
Applying the colon operator to inputs of type char now returns a result of type char. For example,
'a':'g' ans = abcdefg
In previous releases, the same operation returned a result of type double. You may need to change your code if it relies on type double being returned.
The statement str = datestr(..., 'local') returns the date string in a localized format. See the datestr reference page for more information.
The weekday function now takes two new inputs that control the output format. These arguments enable you to get a full or abbreviated day name, and a local or US English output.
When converting between serial date numbers, date vectors, and date strings with the datenum, datevec, and datestr functions, you can specify a format for the date string from the Free-Form Date Format Specifiers table shown on the datestr reference page.
There are two changes that affect importing date information from Excel with the xlsread function:
Prior to this release, xlsread imported date information from an Excel file and returned the results as a double. In Release 14, xlsread returns this information as a cell array containing data of class char. The reason for this is that MATLAB now imports Excel files using an Excel COM server. Excel returns dates is as strings, and there is really no indication that what is returned is a date.
Compatibility Considerations. You will need to change your program code to accept a cell array of type char instead of an array of double when using xlsread to import date information from Excel.
When reading date fields from a Microsoft Excel file using earlier versions of MATLAB, it was necessary to convert the Excel date values into MATLAB date values. This was necessary because Excel and MATLAB calculated date values based on a different reference date. This is explained in the section, Handling Excel Date Values in the function reference for xlsread.
With MATLAB 7.0, you no longer have to do this conversion because xlsread now imports dates as strings rather than as numerical values.
Compatibility Considerations. If your existing code converts Excel date values to MATLAB values, you will need to remove this step so that you end up with the correct results.
The new textscan function reads data from an open text file into a cell array. MATLAB parses the data into fields and converts it according to conversion specifiers passed to textscan in the argument list.
The textscan function is similar to textread but differs from textread in the following ways:
The textscan function offers better performance than textread, making it a better choice when reading large files.
With textscan, you can start reading at any point in the file. Once the file is open, (textscan requires that you open the file first), you can seek to any position in the file and begin the textscan at that point. The textread function requires that you start reading from the beginning of the file.
Subsequent textscan operations start reading the file at the point where the last textscan left off. The textread function always begins at the start of the file, regardless of any prior textread.
textscan returns a single cell array regardless of how many fields you read. With textscan, you don't need to match the number of output arguments to the number of fields being read as you would with textread.
textscan offers more choices in how the data being read is converted.
textscan offers more user-configurable options.
The table below shows new input and output arguments to the xlsread function. See the function reference for xlsread for more information. With the exception of the basic input argument, these arguments are supported only on computer systems capable of starting Excel as a COM server from MATLAB.
New Input Arguments | Description |
|---|---|
-1 | Opens the Excel file in an Excel window, enabling you to interactively select the worksheet to be read and the range of data to import from the worksheet. |
range | Reads data from the rectangular region of a worksheet specified by range. |
basic | Imports data from the spreadsheet in basic import mode. |
New Output Argument | Description |
|---|---|
rawdata | Returns unprocessed cell content in a cell array. This includes both numeric and text data. |
The dlmwrite function now has several new input arguments plus an optional attribute-value format in which to enter these arguments. You can now enter input arguments to dlmwrite in an attribute-value format. This format enables you to specify just those arguments that you need and omit any others. This new syntax for dlmwrite is
dlmwrite('filename', M, attribute1, value1, ...
attributeN, valueN)The former syntax for dlmwrite is still supported for arguments that were available in earlier versions of MATLAB.
The table below shows new input arguments to the dlmwrite function. You must specify these new arguments using the attribute-value format. See the dlmwrite function reference for more information.
Attribute | Value |
|---|---|
delimiter | Delimiter string to be used in separating matrix elements |
newline | Character(s) to use in terminating each line |
roffset | Offset, in rows, from the top of the destination file to where matrix data is to be written |
coffset | Offset, in columns, from the left side of the destination file to where matrix data is to be written |
precision | Numeric precision to use in writing data to the file |
For example, to export matrix M to file myfile.txt, delimited by the tab character, and using a precision of six significant digits, type
dlmwrite('myfile.txt', M, 'delimiter', '\t', 'precision', 6)xlsfinfo now returns the names or all worksheets in an Excel file instead of just the ones with numbers in them (as in Release 13).
The csvread, dlmread, and textscan functions import any complex number as a whole into a complex numeric field, converting the real and imaginary parts to the specified numeric type. Valid forms for a complex number are
Form | Example |
|---|---|
When using the imread function with the 'PixelRegion' parameter, you can now read in portions of an image stored in TIFF format. Specify a cell array containing two vectors, ROWS and COLS, for the value of this parameter. Each vector can either be a two-element vector specifying the extent of the region, [START STOP], or a three-element vector that enables downsampling, [START INCREMENT STOP].
When used with tiled images, 'PixelRegion' subsetting can improve memory usage and performance because it only reads in the tiles that encompass the region. For example, in the following figure, if you specify the region defined by the box, imread would only read in tiles 1, 2, 4, and 5.

MATLAB now includes a function, named mmfileinfo, that returns information about the contents of a multimedia file. The file can contain audio data, video data, or both.
This function is only available on Windows platforms.
The MATLAB audiorecorder and audioplayer functions can now be used on Windows and UNIX platforms. These functions were previously only available on Windows systems.
Note The audiorecorder and audioplayer objects are now implemented as MATLAB objects on all platforms. The methods supported by these objects are overloaded functions. You must use standard MATLAB function calling syntax to call methods of these objects; you cannot use dot notation. |
From within MATLAB, you can connect to an FTP server to perform remote file operations. For more information, see the ftp reference page.
MATLAB can now consume Simple Object Access Protocol-based (SOAP) Web services with the createClassFromWSDL function. For more information, see Using Web Services with MATLAB in the online documentation.
The release notes for MATLAB Release 13 should have included MacIntosh in the list of those platforms that support 64-bit file handling. This support is available on the following platforms:
Windows
Solaris
Linux 2.4.x
HP-UX 11.0, 9000/785
Macintosh
The last two lines of MATLAB error messages have changed for Release 14. Error messages now
Each of these changes is discussed below. Examples show the errors generated by both the previous release (V6.5) and current release (7.0) of MATLAB for the purpose of comparison.
MATLAB now calls out the source of the error using a consistent format. One of the features of this format is that you can place the string of the message into other MATLAB commands. See Using the Error Message String as Input to Other Functions.
Errors Generated by the Primary Function. Errors generated by the primary function of an M-file are displayed as shown below. In version 7.0, the path is not shown in most cases (private functions are one exception). Filename extension is also not shown. The failing line number is shown on third line.
In MATLAB V6.5 —
??? Error using ==> strcmp
Too many input arguments.
Error in ==> B:\MATLAB_V70\work\errmsgtest.m
On line 11 ==> strcmp('aa','bb','cc');
In MATLAB V7.0 —
??? Error using ==> strcmp
Too many input arguments.
Error in ==> errmsgtest at 11
strcmp('aa','bb','cc');
Errors Generated by a Subfunction. Errors generated by a subfunction of an M-file are displayed in the previous release and current release of MATLAB as shown below. Comments for primary functions apply here as well. Also, the name of the failing subfunction follows the > character instead of being put in parentheses.
In MATLAB V6.5 —
??? Error using ==> strcmp
Too many input arguments.
Error in ==> B:\MATLAB_V70\work\errmsgtest.m (subFun1)
On line 17 ==> strcmp('aa','bb','cc');
In MATLAB V7.0 —
??? Error using ==> strcmp
Too many input arguments.
Error in ==> errmsgtest>subFun1 at 17
strcmp('aa','bb','cc');
This example shows an error that comes from a nested function (nestFun2) called by another nested function (nestFun1). It uses the following syntax, where the > character follows the name of the primary function and precedes the names of any nested functions.
fun>nestfun1/nestfun2/etc at lineno.
In MATLAB V6.5 —
Nested functions are not supported prior to version 7.0.
In MATLAB V7.0 —
??? Error using ==> strcmp
Too many input arguments.
Error in ==> errmsgtest>nestFun1/nestFun2 at 6
strcmp('aa','bb','cc');You can copy the text of the line that calls out the source of an error and use this string as input to some of the MATLAB debugging functions. The example shown below uses the string in a call to the dbstop function.
Copy the text that begins after
Error in ==>
In MATLAB V6.5 —
This feature is not supported prior to version 7.0.
In MATLAB V7.0 —
??? Error using ==> strcmp
Too many input arguments.
Error in ==> errmsgtest>nestFun1/nestFun2 at 6
strcmp('aa','bb','cc');Copy and paste text of this error message into the dbstop command:
dbstop errmsgtest>nestFun1/nestFun2 at 6
Error messages now contain a blue-underlined hot link to the failing line of the M-file being executed.
If any of your programs rely on specific text in the types of error messages described here, you may have to modify your program code.
When the nargchk function detects an error condition, it returns information on the error in either a string or a MATLAB structure. Use one of these two command syntaxes to specify which format to return. If neither is specified, nargchk returns a string:
msgstring = nargchk(minargs, maxargs, numargs, 'string') msgstruct = nargchk(minargs, maxargs, numargs, 'struct')
The return structure has two fields: the message string, and a message identifier . When too few inputs are supplied, these fields are
message: 'Not enough input arguments.'
identifier: 'MATLAB:nargchk:notEnoughInputs'When too many inputs are supplied, the structure fields are
message: 'Too many input arguments.'
identifier: 'MATLAB:nargchk:tooManyInputs'The following message, which MATLAB appended to all warning messages in the previous release, is no longer displayed.
(Type "warning off <msgid:msgstr>" to suppress this warning.)
Use the off and on options of the warning function to control the display of all or selected warnings. This example disables a selected warning, and then enables all warnings:
% All warnings are enabled by default.
A = 5/0;
Warning: Divide by zero.
% Disable the most recent warning
[msgstr msgid] = lastwarn;
warning('off', msgid);
% Try it again. This time there is no warning.
A = 5/0;
% Enable all warnings
warning('on', 'all')
% Verify that the warning is reenabled.
A = 5/0;
Warning: Divide by zero.In previous releases of MATLAB, typing Ctrl+C while executing the try part of a try-catch statement resulted in the program branching to the catch part of that statement. In this release, typing Ctrl+C is purposely not caught by try-catch statements.
The reason for this change is that, under certain circumstances, this behavior in try-catch statements was found to adversely affect internal MATLAB code. In these cases, this resulted in MATLAB code catching the Ctrl+C rather than responding appropriately to it by terminating the current operation.
Release 13 introduced a new performance acceleration feature built into MATLAB. Enhancing performance in MATLAB is an ongoing development project that continues to show significant improvements in the performance of MATLAB programs.
The Performance Acceleration documentation written for Release 13 included suggestions on specific techniques to make the most of this feature. In this release, many of those techniques are no longer necessary. This documentation has been replaced with more general suggestions on how to improve the performance of your programs.
Due to the increasing size of the printed "Using MATLAB" manual, we have divided it into three separate printed books in version 7.0 to make it more manageable. The titles for these books (and their corresponding headings in the MATLAB Help Browser) are
Desktop Tools and Development Environment
Mathematics
Programming
The online structure of this documentation is very similar to what it has been in previous releases, although some topics are now covered more thoroughly. We hope that you find this new format easier to use.
![]() | Mathematics, MATLAB Version 7 (R14) | Graphics and 3-D Visualization, MATLAB Version 7 (R14) | ![]() |

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 |