It’s yet again that time of the year. A new MATLAB release just came out.

I know that there are plenty of great features that could have made it to the list, which doesn’t mean I don’t find them relevant or useful. These are the ones that I believe that will be more relevant to me in the coming months.

So let’s cut to the chase and visit my favorite new features in MATLAB R2021b:

10. Exporting Animations in the Live Editor

Exporting animations got easier with the Live Editor. You can export animations to movies or GIFs simply by using the new Export Animation button.

Exporting Animations with Live Editor

Click the image to play the exported animation from MATLAB

9. Test class template

Testing your code is an integral part of developing quality software. For me, testing is like breathing. If you don’t (adequately) test your code, it will eventually die. With the existing testing frameworks in MATLAB, you can write unit tests, performance tests, test your apps, or test a portion of your complete system in isolation using mock objects to replace the dependencies.

MATLAB R2021b includes a TestCase class template to speed up the creation of your tests. You need to go to New > Test Class in the Home, Editor, or Live Editor tabs:

New Test Class

This brings up the following template so that you can create the test more conveniently:

New Test from Template

Interestingly, the default test class coming out of the template fails right away, so that you start to implement your tests and your code. Moreover, it includes several method blocks (TestClassSetup, TestMethodSetup, and Test) to begin customizing your tests.

There is a brilliant presentation by my colleague Heather Gorr, Ph.D. where she covers test-driven development, among other topics:

:point_right: Would you trust your model with your life? Research vs. reality in AI

8. New live tasks

I must admit that I don’t use Live Tasks often. However, every time I do, my mind explodes. This new release brings Compute by group and Normalize Data live tasks to MATLAB, and the Cluster Data live task to Statistics and Machine Learning Toolbox. Of all, my favorite, maybe also due to the UX experience, is Compute by Group. Grouping data and computing statistics, transformations, or filtering operations on each group couldn’t be more effortless with this live task. Of course, the task automatically generates MATLAB code for you.

See it in action by yourself:

Compute by group live task

7. Cuda optimized code for ROS Nodes

In the past, I have deeply suffered the process of bringing CUDA code from a Deep Neural Network (generated from GPU Coder) to ROS nodes. It required having to manually integrate the generated library inside a handwritten C++ ROS node.

In this release of ROS Toolbox, you can now generate and deploy CUDA-optimized code for ROS nodes directly from your Simulink model. Simply beautiful.

Export ML model

See it for yourself with this Lane and Vehicle Detection example.

6. backgroundPool

I have frequently received feedback from MATLAB users who wanted to run code asynchronously, forcing them to use Parallel Computing Toolbox. Usually, MATLAB suspends execution while running calculations. And if you are developing an app, for instance, this might affect its responsiveness.

It’s worth noting that Parallel Computing Toolbox provides an API for a broad range of parallel programming paradigms, GPU computing, and an API to bring your processing to clusters and HPCs (including Big Data Frameworks like Hadoop or Spark).

Although having access to Parallel Computing Toolbox will have added benefits (access to more threads basically), MATLAB users can now run a single worker as a thread in the main MATLAB process. This facilitates asynchronous workflows (using backgroundPool to open the pool and parfeval to run your functions in the background).

You can check here an example of how your app can be more responsive with backgroundPool.

5. PointNet++

PointNet and PointNet++ papers (1, 2) fall in this category of research papers that I have read thoroughly. I might post one day on these two papers and why PointNet++ is an excellent choice for segmenting point cloud data.

PointNet++

But for now, you no longer need to figure out how to create a PointNet++ network with the extended DL framework in MATLAB (as was the case in R2021a) and pointnetplusplusLayers does the job right away. For instance, you will be able to solve semantic segmentation on point cloud data from aerial lidar:

Semantic Segmentation using PointNet++

  1. Charles R. Qi, Hao Su, Kaichun Mo and Leonidas J. Guibas, “PointNet: Deep Learning on Point Sets for 3D Classification and Segmentation”, 2017 IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 2017 https://arxiv.org/abs/1612.00593v2
  2. Charles R. Qi, Li Yi, Hao Su, and Leonidas J. Guibas. “PointNet++: Deep Hierarchical Feature Learning on Point Sets in a Metric Space”, ArXiv:1706.02413 [Cs], June 7, 2017. https://arxiv.org/abs/1706.02413

4. Your Machine Learning model to production is one click away

Once you have trained a Machine Learning model using Classification Learner or Regression Learner, bringing it to production is just one-click away.

Export ML model

This will create a deployment project for MATLAB Production Server and autogenerate the required MATLAB code to serve your model in production. You can find examples for Classification Learner and Regression Learner apps here and here.

3. pyrun and pyrunfile

Ever since the first version of the Python interface was shipped in MATLAB R2014b, I have been a true and loyal fan. The interface not only does the job of calling Python from MATLAB, but I also believe that it is a beautiful implementation design. If you’d like to check the doc, you can certainly do so. However, I recommend you watch one of the multiple talks available online, where my colleagues Heather and Yann discuss use cases, workflow, and tips on using the two languages together:

As incredible as the interface might seem to me or others, I understand it may not be practical for those who just need to run a snippet or script of Python code. With pyrun and pyrunfile you can now call Python commands and scripts from MATLAB:

>> pyrun("from __future__ import braces")
Python Error: SyntaxError: not a chance (<string>, line 1)

This is one of the funny easter eggs in CPython regarding having braces to control flow. You can do more meaningful stuff to exemplify your use case; indeed, I simply find this one quite funny.

2. Git workflow in MATLAB Online

In simple terms, MATLAB Online is simply MATLAB on your web browser. No downloads. No installs.

Git integration has been part of MATLAB for a long time now. Starting in R2021b, MATLAB Online provides support for basic Git workflows:

New from Git

You can now clone, commit, pull, push and fetch files to and from your MATLAB Drive:

Cloning a repo

1. Updates to the MATLAB Editor

If you got so far reading, my top pick has been the updates to the MATLAB Editor. This may not seem a fancy pick to you. For quite some time now, there were a considerable number of coding features that were available for Live Scripts but not for plain code (.m files to be clear). For those of us who still maintain a lot of code in plain code, it frequently came with a loss in productivity. :umbrella:

The MATLAB Editor now supports a rich set :sunny: of features for your MATLAB code (in .m files):

  • Zooming in and out your code
  • Tab completion
  • Assistance with auto syntax completion
  • Smart parameter suggestion as you are filling in function calls
  • Enhanced debugging
  • Code refactoring
  • Code block selection
  • Bookmarks
  • Case-change of text

My life just got a lot easier with R2021b.

Check the latest features in the release notes, and feel free to share your favorites with me.

Comments