| Programming, MATLAB Version 7.0.4 (R14SP2) Release Notes | ![]() |
This version introduces the following new features and changes:
Memory-mapping is a mechanism that maps a portion of a file, or an entire file, on disk to a range of addresses within an application's address space. The application can then access files on disk in the same way it accesses dynamic memory. This makes file reads and writes faster in comparison with using functions such as fread and fwrite.
Another advantage of using memory-mapping in MATLAB is that it enables you to access file data using standard MATLAB indexing operations. Once you have mapped a file to memory, you can read the contents of that file using the same type of MATLAB statements used to read variables from the MATLAB workspace. The contents of the mapped file appear as if they were an array in the currently active workspace. You simply index into this array to read or write the desired data from the file.
Memory-mapped files also provide a mechanism for sharing data between applications. This is achieved by having each application map sections of the same file. This feature can be used to transfer large data sets between MATLAB and other applications.
The textscan function originally read data only from files. As of this release, you can use textscan to read from strings as well.
In this release, you can write a function and pass a handle to this function to xlsread. When xlsread executes, it reads from the spreadsheet, executes your function on the data read from the spreadsheet, and returns the final results to you.
You can use either of the following syntaxes:
num = xlsread('filename', ..., functionhandle)
[num, txt, raw, X] = xlsread('filename', ..., functionhandle)See Example 5 — Passing a Function Handle on the xlsread reference page.
In MATLAB versions prior to R14, date values read into MATLAB from an Excel spreadsheet using xlsread were always imported as numeric date values. The R14 and later releases of MATLAB import dates in the format in which they were stored in the Excel file. Dates stored in string or date format are now imported as strings by xlsread. Dates stored in numeric format are imported as numeric date values.
Because of a difference in the way Excel and MATLAB compute numeric date values, any numeric dates imported from Excel into MATLAB must be converted to the MATLAB format before being used in the MATLAB application. See Handling Excel Date Values on the xlsread function reference for information on how to do this.
You can display MATLAB output using two new formats: short eng and long eng. See the format reference page for more information.
short eng — Displays output in an engineering format that has at least 5 digits and a power that is a multiple of three.
long eng — Displays output in an engineering format that has exactly 16 significant digits and a power that is a multiple of three.
format short eng
pi
ans =
3.1416e+000
format long eng
pi
ans =
3.14159265358979e+000Creation of nonscalar arrays of function handles by str2func may be invalid or may return different results in future versions of MATLAB, but will continue to work in R14.
To avoid this warning and prepare for this change, convert the cell array of strings to a cell array of function handles.
For more information, type help function_handle and see the section entitled Note on Backward Compatibility.
Assigning to a nonstructure variable as if it were a structure is not recommended in MATLAB. For example, if variable x holds a double (as shown below), then attempting to add a fieldname to it, thus converting x to a structure, is not good programming practice and should generate an error.
x = 10; x.name = magic(3);
Note that if x were empty (i.e., x == []), then assigning a field to it as if it were already a structure is acceptable.
Because of a bug in releases of MATLAB prior to R14, you can assign a field to a nonempty, nonstructure variable in those releases without MATLAB generating a warning message or error. The result is that MATLAB quietly converts the variable to a structure:
x = 10;
class(x)
ans =
double
x.name = magic(3); % Invalid expression completes
% without warning or error.
class(x)
ans =
structIn the MATLAB R14 and R14 service pack releases, you can still perform this type of operation, but MATLAB now displays a warning message:
x = 10; x.name = magic(3); Warning: Struct field assignment overwrites a value with class "double".
In a future release of MATLAB, attempting this type of operation will throw an error instead of just displaying a warning message.
You are encouraged to modify any code that generates this warning. The section Making a Valid Assignment gives instructions on how to do this.
The same rules apply when extending the depth of a structure by adding additional, lower-level fields. The first line of the example shown below creates a structure named handle and assigns to it a field of type double named output. The line after that treats this double as if it were a structure by attempting to assign a field named time to it. The second line is an invalid expression:
handle.output = 5; handle.output.time = 13;
As in the case discussed earlier, this assignment does not generate a warning or error in MATLAB releases prior to R14. In the R14 and R14 service pack releases of MATLAB, you get the warning shown in the previous example. Beginning in a future release of MATLAB, this assignment will throw an error.
To avoid this warning and future errors, first make x an empty structure or empty array as shown here. Once a variable is established as a structure or empty array, you can assign fields to it without getting an error:
x = struct; or x = []; x.name = magic(3);
In the case of extending the depth of an existing structure, you can perform this type of assignment without generating a warning or error using the struct function as shown here:
handle.output = struct('time', 13);As of Release 14, the function definition line in a function M-file no longer requires commas separating output variables. However, because this syntax is not compatible with earlier releases, you should always include the comma separators when writing an M-file function that you intend to run on releases both earlier and later than Release 14.
See Comma Separators Not Required in Function Declaration in the Release 14 release notes.
![]() | Mathematics, MATLAB Version 7.0.4 (R14SP2) | Graphics and 3-D Visualization, MATLAB Version 7.0.4 (R14SP2) | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |