https://www.acsysteme.com/wp-content/uploads/2021/07/matlab-R2008a-vers-R2012b-1.jpg

What’s new in Matlab between R2008a and R2012b?

1. What about object oriented programming ?

One of the most significant upgrades of Matlab during the last few years was made with object-oriented programming. Indeed, Matlab changed its syntax dedicated to object-oriented programming and added concepts and rules that already exist in other object languages, like classes and references. A class-defining file is recognised thanks to the keyword classdef. A Matlab class describes properties, methods and events. It can be organised in a package to manage the name space and facilitate the syntax during their calls. References to objects are possible with the keyword handle and allow object handling without copying it. However, since the R2011a release, the class copyable brings a new behavior when copying a handle class.

In addition, to implement lookup tables, Matlab has created, since R2008b, a new kind of data: containers.Map. It is a good point for Python or Perl programmers who are familiar with these data types. From now on, it is possible to index a table with a “key”. A key can be a real number or a string instead of a positive integer, so it means more flexibility to access data. You can store all kind of data (matrix, structures, cells, strings, object and even other Maps). This type of data combines readability of structure and ‘container simplicity’ of cell arrays.

 % containers.Map
% Building

myKeys = {‘key1′,’key2′,’key3’};
myValues = {ones(3),‘stuff’,123};

myObject = containers.Map(myKeys, myValues);
% Or else
myObject2 = containers.Map({‘key1′,’key2′,’key3’},{ones(3),‘stuff’,123});

% Get and display elements in container
Key = keys(myObject)
Values= values(myObject)
Values1 = myObject(‘key1’)

Key =
‘key1’    ‘key2’    ‘key3’

Values =
[3×3 double]    ‘stuff’    [123]

Values1 =
1     1     1

     1     1     1

     1     1     1 

When programming, cleaning tasks (closing files, restoring the default path…) can be specified after running a function thanks to the object: onCleanup.

 %% Exemple onCleanUp to ensure file closure in case of error
function strText = lireFichier(nomFichier)

% Open file while reading it
fid = fopen(nomFichier, ‘rt’);
if fid<0
error(‘lireFichier:ImpossibleOuvrirFichier’,
‘Impossible d”ouvrir %s\n’, nomFichier);
end

  % Add on CleanUp object to close file when returning function
objCleanup = onCleanup(@() fermeture(fid, nomFichier));

  % Read file
strText = fread(fid, ‘*char’)’;

  % Send error if the file is empty
if isempty(strText)
error(‘lireFichier:FichierVide’, ‘Le fichier est vide’);
end

     %% Function that is run by objCleanUp when ending the function
function fermeture(fileID, fileName)
fclose(fileID);
fprintf(‘objCleanup : fermeture du fichier “%s”\n’, fileName);
end
end
 

2. Still evolving (new editor, comparison tools, graphs, brush, import/export)

Matlab keeps evolving with each version to facilitate programming. Most of these changes were made for the development environment (IDE) so as to refine it.

2.1 Editor upgrades

The editor has gone through an update. New functionalities give a better handling of functions and variables with automatic renaming, finding every use, identifying shared variables between nested functions or improving the function browser.

On a visual aspect, browsing in the programs is now more user-friendly with folding – code with a higher indentation can be hidden – or access to list for nested functions, sub-functions, local variables.

The variable editor was supplemented with new information on structures and objects and by selecting non-adjacent cells in matrices.

https://www.acsysteme.com/wp-content/uploads/2021/07/ressource-evolution-Matlab-code-folding.jpg

Example of code folding in a “for” loop

Plot catalog

https://www.acsysteme.com/wp-content/uploads/2021/07/ressource-evolution-Matlab-choix-graphes-Matlab.jpg

2.2 A real tool to compare files

To help users compare different files, Matlab has perfected its comparison tool (Desktop menu > Comparison Tool). It previously applied only to text files (.txt) but now it has also became available for M-files (.m) and MAT-files (.mat) since R2008a. The tool highlights differences between files (.txt and .m). With MAT-files, there is now the possibility to merge differences between variable values. Recently, the tool now compares directory, binary files or their archives (.zip), and rejects from results unchanged elements or specified type of elements. People who are used to WinMerge or similar tools will get their bearings.

2.3 Plot selector

Creating graphs is now easier thanks to Plot Selector in the workspace. This catalog eases browsing, and the search for available and relevant plots – including those from a toolbox. Moreover, you can add to favorites some plots and display only them (using the little star to the right of graphs).

2.4 Interactively brush your data

Another new feature, variables in the workspace are now linked to plot. A graph related to data is interactively updated when data changes.

Brushing allows the user to select a part of the curve with the cursor and set it to red. Then, you can either drag’n’drop data in the command window to get numerical values or you can remove the chosen part by turning numerical data into NaN.

Any action performed is immediately reproduced on other plots linked to the same data in the workspace.

With GUIDE, a graphical user interface editor, the new component provides the opportunity to display and edit table data.

https://www.acsysteme.com/wp-content/uploads/2021/07/ressource-evolution-Matlab-brushing-Matlab.jpg

Data plot linked to variable x,y

https://www.acsysteme.com/wp-content/uploads/2021/07/ressource-evolution-Matlab-brushing-liaison-Matlab.jpg

Brushing functionality and data link

2.5 Import and export

As Matlab is used with other external interfaces, it enhances its capability to handle input and output files. Among those improvements, you can now create MPEG video clip with VideoWriter functions, read Excel files (.xlsx) with Mac and Linux, or even manage NetCDF files, self-describing files to store scientific data.

As far as figure and M-File exporting is concerned, Matlab has been able to export these files in different formats (Publishing), such as PDF since R2009b. Nevertheless, you need to keep in mind that some output formats can be corrupted or denied because exporting depends on the match between the Matlab version running and its system software version.

https://www.acsysteme.com/wp-content/uploads/2021/07/ressource-evolution-Matlab-publier-code-Matlab.jpg

Publication of Matlab code

3. Performance

Matlab enhances its computation performance by improving its mathematical functions and parallelisation tools so as to reduce processing time when dealing with big data. With a more powerful JIT compiler, instructions in command lines – and in cells within the editor – are running faster in the environment.

Then, a lot of mathematical functions and arithmetic operations mainly used with matrix calculation are more efficient thanks to multithread computation with multicore computers (fft, sum, prod, min, max, sort, filter, bsxfun, sparse matrix QR, conv2, mrdivide, convn, histc, sortrows,…)

To improve data interpolation performance, Matlab changed the interpolation formula (interp1, interp2, interp3 and intern) and griddedInterpolant class so as to optimise memory efficiency to interpolate data grids.

Mathematically speaking, FFT functions now support 2Gb-sized arrays and the rng function, with the R2011a release, got higher possibilities with random number generation than with rand or randn. You can now choose to keep the same random seed for another generation or you can avoid generating the same numbers when you restart Matlab (rngshuffle).

At last, memory function charts memory state (you can now display the size of the biggest memory block available so as to diagnose memory related issues).

4. 64 byte management ?

Mathematically, the R2010b version supports arithmetic with 64-bit integers. The double type is not able to represent integers higher than 2^53, in which case results are corrupted. From now on, it is possible to compute with 64-bit integers for more accurate results than before.

https://www.acsysteme.com/wp-content/uploads/2021/07/Interface-de-Matlab-8.jpg

5. Matlab 8.0

Downloadable from the MathWorks website, the R2012b release has a revamped graphical interface and some new features.

Some of the new features are the abstract class declaration, the possibility to recover Java exception through matlab.exception.JavaException class or the loss of compiler material for Linux 32-bits GNU gcc Version 4.4x et GNU gfortran 4.3.x.

In the field of applied mathematics, logical functions are now running with signed integers or in bit-to-bit mode (bitand, bitor, bitxor…), trigonometric functions can take degrees (sind, cosd, tand, asind, acosd…) and complex numbers in an argument, or we can enjoy some optimisations made with Bessel functions, airy and psi. Finally, you can also solve differential equations with neutral type delay or delays independent from state thanks to the ddensed function.

Some new features facilitate the import/export data process. The Import Tool helps you import, in one go, matrix data like numbers, dates, text to convert them into column arrays. In terms of multimedia, the audioread and audioinfo functions can import MP3, MPEG-4 and ACC files while audiowrite makes MPEG-4 writing happen. We can also handle BigTIFF files over 4Gb or even read XLSM, XLTX or XLTM files thanks to xlsread on every platform.

Share this post: