21 MATLAB Features You Need Now - MATLAB
Video Player is loading.
Current Time 0:00
Duration 21:37
Loaded: 0.76%
Stream Type LIVE
Remaining Time 21:37
 
1x
  • descriptions off, selected
  • en (Main), selected
    Video length is 21:37

    21 MATLAB Features You Need Now

    Overview

    Are you getting the most out of MATLAB, or are you still using it just the way you were taught your first year in University? With over 2,000 people working year-round to design, build, test, and document MathWorks products, it is a safe bet that there are more than a few useful features that you don't know about. Some features will be very new, while others may be 5, 10, or maybe even more than 15 years old. How many of them will be new to you?

    About the Presenters

    Michelle Hirsch, Ph.D.

    Hirsch is the head of MATLAB Product Marketing and Product Management at MathWorks. Michelle drives overall strategy, direction, and messaging for MATLAB. She is a principal design coach and develops and delivers MathWorks most visible keynote presentations.

    Heather Gorr, Ph.D.

    Heather Gorr holds a Ph.D. in Materials Science Engineering from the University of Pittsburgh and a Masters and Bachelors of Science in Physics from Penn State University. Since 2013, she has supported MATLAB users in the areas of mathematics, data science, deep learning, and application deployment. She currently acts as a Senior MATLAB Product Marketing Manager, specializing in data science, AI, and integrating MATLAB and Python code. Prior to joining MathWorks, she was a Research Fellow, focused on machine learning for prediction of fluid concentrations.

    Recorded: 10 Sep 2020

    Hey, my name's Michelle Hirsch. I'm the head of the MATLAB product management and product marketing team. My team works with the software developers at MathWorks to make sure that each release of MATLAB is better and more useful than the one before.

    Hi, I'm Heather. And I'm actually on Michelle's team. I focus on data science in MATLAB.

    We're so glad to have you join us today. We've got two goals for our talk. The first, of course, is to show you 21 features that you need now, to show you some of our favorite features that we use every day in MATLAB, and then we hope you'll be interested in trying out for yourself. The second is to peak your curiosity, to encourage you to ask the question, maybe there's a feature in MATLAB that already does what I'm trying to do, that can help me do this in a better way.

    Now, probably not surprisingly, but Heather and I and our other co-workers communicate with each other a lot through MATLAB. We make and share plots and scripts and apps. But I find that I typically need to walk somebody through what I've done, to explain how this is what this means by this plot, et cetera. But not anymore.

    With the Live Editor, I can write MATLAB scripts that look like this. This is some analysis that Heather and I have been doing on the magnitude and location of earthquakes around the world. With live scripts I can include richly formatted text with hyperlinks, embedded images, and embedded equations that I can edit with this convenient Equation Editor.

    And of course, it's in MATLAB code. Of course, there's MATLAB code here. So I run the code, the output is immediately right here in place. And it's richly interactive.

    And so I can zoom in and pan around. So here we see a plot of the latitude and longitude, the coordinates of earthquakes around the world. You'll notice that as I interactively explore my plot, this code here on the right-hand side is automatically generated.

    I can click Update to insert that in along with the code that I wrote by hand, so then next time I run this section, I get exactly the same output. It's a really nice combination of convenient, rapid, interactive workflows with automatic co-generation, so I can repeat the work that I've already done. Now, plots in the Live Editor interactive-- plots, actually, in all of MATLAB are now interactive. So as I pop this plot out to look at independently, I can again zoom and pan, rotate 3D plots, and add data tips without having to shift between modes.

    Now, this is admittedly not the most convenient way to look at the locations of something spread across the Earth. It'd be much more convenient to look at them, I don't know, on a map. And that's now quite straightforward to do in MATLAB with support for geographic plots.

    So here I'm showing what's called a geobubble plot. So it's a bubble chart where the size of each circle reflects the magnitude of the earthquake. And its geographic. It's plotted on top of a map.

    One thing that's really convenient working the Live Editor is by having code and output in the same place, it's really easy to make little changes to the code and see the impact that they have. So for instance, here I'm changing the values of a parameter that sets the threshold for the smallest magnitude earthquake we show in my plot. Now, as Heather and I walk you through the different new features, we're going to use this feature tracker app to keep track, remind us of what we've seen. And also to keep count, to make sure we show you the 21 features we promised.

    Now, the first is the introduction to the Live Editor for creating rich interactive scripts in MATLAB. And those scripts can include formatted text, images, and equations. And we saw that their output is embedded directly in place and is fully interactive.

    We popped out the plot to see that all plots in MATLAB are now interactive by default. And we touched briefly on the ability to create geographic plots and maps, plotting your data on top of a map.

    Let's use that same script Michelle was using, but we'll take it one step further, and let's say we want to share with somebody who doesn't really want to look at the MATLAB code. Or we only really want them to change that earthquake magnitude and have it update the plot. We could use a live control, so I'll just create a numeric slider.

    So the person, say it's a manager or somebody that doesn't want to-- we just want them to look at the updates, we can see this immediately. And if we want to take it one step further, we can actually hide the code altogether. So we can change the view in the Live Editor, and that way, it can just look-- change the slider and then update the view immediately without looking at the code.

    Taking it another step further, we could share it with, say, that person's manager that doesn't need to look at any of the MATLAB code-- that's wants a report, basically. So you can save it as a PDF, a Word document, HTML. And then you basically have a report of what we just did.

    So what did we just see? We saw some great options for sharing, like using interactive controls, hiding our code, and then exporting as a Word doc or a PDF so we can share with others.

    That's cool, Heather. I really loved how you built on what I did, and you could take that variable I was changing by hand and just turn it into a slider to build, effectively, a little app right there in place of the script. Now, sometimes when I make apps, I want them to be quite a bit more elaborate, with offering more flexible, open-ended workflows to the users. Like this app here that we built for visualizing earthquakes.

    So it's still extending the same data set, but just giving more flexibility. For instance, selecting the date range of the earthquakes that we want to analyze, and controlling not just the minimum magnitude, but also the depth. And as I change each of these, to be able to quickly flip through and look at different types of visualizations to understand what's happening with the data, whether it's that geographic bubble chart, or maybe even just a simple table of the raw data.

    Now, we built this app using App Designer. This is a feature that comes with MATLAB for building and sharing interactive applications. What we see in the center is the canvas where we've designed our app. And on the left-hand side, we see various components that we can just drag and drop into as we design our app. So for instance, adding a tree here.

    App Designer lets me layout and get things looking exactly the way I want, and then it automatically writes the MATLAB code for me. I then just fill in the details of the code to get the specific behavior that I want to present to users or to respond to user interaction. Once I've got the app just where I want, there's a lot of flexibility for how I share it. I can share it with other users as a MATLAB app that they can install and run inside of their version of MATLAB, just like I did a moment ago; as a standalone desktop application that runs with no MATLAB installed; or my favorite way, as a web app.

    So I can just push this out to a web server, and it's available for anybody in the organization to run directly from in their web browser. And that's what I'd like to show here. So I'm switching from MATLAB to Google Chrome, which is my web browser of choice. And the story here is it's the app, the same interactions, the same ability to explore all the data visualizations all right here, built in.

    So what have I shown you? Couple of things. We saw App Designer for building and sharing interactive apps. And we saw the ability to share those apps as web apps directly accessible from within a web browser.

    Let's talk about data. It's kind of my thing. But we're not going to talk about the fun stuff that will make you famous, like deep learning or machine learning algorithms. We're going to talk about all the things that will lead you there-- cleaning up the junk in your data, the pre-processing and data prep that you need to get to that point.

    We have energy data that we're using from New York state that we'll bring into MATLAB. So we're going to read a timetable. This is actually time series data.

    We have a timestamp, and then the data information for each county in New York state. So we'll select our data. And then you notice that this is some live function hints. So something like readtable, which I'm pretty familiar with. I don't need to go to the documentation. I just need a reminder of what options I have-- super, super helpful.

    So I'm using a timetable. We'll talk more about this in a second. But we'll bring it in. And you can see that there's a timestamp, and then each county and the data that is associated with that county for that time.

    So timetables are great for dealing with data like this. They have the time associated, and so we'll be able to use that throughout. So we haven't seen this data before. I don't know about you, but the first thing I want to do is just take a look visually.

    So we can take a look at the Plots tab, actually. I don't know if you know about this one. This is actually a longstanding feature that is really super useful for visualizations like this.

    You can take a look and see all of the visualizations that are available in MATLAB. And then if you select the data, so our energy data that we just brought in from MATLAB, we can actually see what plots are available for that data. So in this case, I'll use a stack plot. Super helpful, because it shows all of the variables as a function of time together.

    So as you can see here, we'll talk about some outliers, some missing data. But it's really handy to be able to see everything in one place and just get a sense of what we're working with. So let's go back to our script. And we're going to work with our data some more.

    So let's look at one county. We looked at everything all together, but let's just dig into one. And so you notice there are definitely a few outliers here that we probably want to take a look at. And then there are a lot of zeros.

    In this case, zeros are actually missing data points. So that is important for us. We need to be able to handle missing data points and deal with them appropriately. And there are some great functions in MATLAB recently that will help you do that. So for example, standardize missing, we can change those zeros to actually missing data. And then we can fill them with linear interpolation.

    So we remove some of our missing data, but we still have these outliers. So we'll take care of those now and just try to remove some of them. So let's run this line of MATLAB code.

    I don't know about you, but this looks like a very strange line of MATLAB code. Let's see if it runs. Sure enough, it does. And it gives me this awesome plot that shows me my outliers, and which ones were clean and filled.

    I'm also going to dazzle you with a bunch of features in one second. So I'm going to put the output on the right so that I can make some updates and look at this all together. And I'm going to expand this, because this is actually a nice little app that I can use. It's called a live task, a Live Editor task.

    And I can update some of these things. So in this case, it's using linear interpolation in our median method. I want to see what's going to happen if I use a different method. And so you can quickly change these and see what happens in the plot-- very, very useful.

    It also includes the code. So everything that you need to do to do the outlier detection and filling and the visualization is there for you whenever you need it. And so these are super helpful. I love using these for these data processing tasks that are very iterative.

    But we'll pause here, because we showed a lot of stuff and I want to take credit for them. One is the function hints in the Live Editor. So we saw that was super helpful. Timetables, near and dear to my heart; stacked plot, very useful; our Plots tab, which has been around for a very long time; missing data functions; and then our Live Editor tasks; and side-by-side mode that we were able to use very usefully.

    Now, that's a really interesting analysis, Heather. And I saw something in the data that I'd like to dig into just a little bit further. I'm trying to better understand the periodicity of what's happening as the data varies over some repeating pattern. So what I'd like to do is look at the data in both time domain and frequency domain. That, as you can imagine, is a really common task in MATLAB.

    Now, anytime you're doing some common task in MATLAB, I encourage you to take a peek at the Apps tab. This is where we went before to launch our earthquake visualizer. But the Apps tab includes up to about 100 apps from various MathWorks products for simplifying all sorts of common tasks, whether they're for developing machine learning classifiers or deep learning networks, designing and analyzing control systems, or doing signal processing analysis or communication system design.

    That's where I can find the Signal Analyzer, which has become my go to app for working with time domain and frequency domain data. Here I've got the data that Heather had just cleaned up. I can just drag it over to import it into the app. And it's a timetable, so I can drill down and select which variables I'd like to look at.

    So let's look at a time domain plot on the Dunwoody County. We can zoom in and try to see what's happening here. And we look at the different frequencies of data involved. And pan around.

    Then also look at this in the frequency domain on the right-hand side. Because I'm trying to understand that sort of low frequency variation, we'll zoom down into the lower frequency range, throw in a couple of data cursors, and just get a quick and dirty ballpark estimate of what's going on. If we look at these first couple of values, we see they're at around 0.04, there are 0.08 cycles per hour, which if you invert those translates to once every 24 hours and once every 12 hours, which is, I'd say, reasonable for what we might expect when we're working with type of energy consumption data.

    Now, Heather and I have both shown you several ways of working with data and problem solving interactively in MATLAB. But of course, what we all love about MATLAB is the access to the flexible programming languages so we can do anything we want and automate our workflows. And the same thing is true when we're working with apps. We can do things interactively.

    But we could also generate MATLAB programs. For instance, here I'm generating a MATLAB program automatically to select a region of interest within the time domain, and then perform that same spectral analysis in the frequency domain. So what have we seen? We've seen a couple more things-- the signal analyzer, my go-to app for working with time domain and frequency domain data, and more generally, apps, almost 100 apps that come with MathWorks products for working through all sorts of common tasks.

    Thanks, Michelle. Super helpful. I love using the apps in some MATLAB. We're going take a break, have some fun, and we're going to take some pictures. I can actually use my webcam in MATLAB and take a picture.

    So I actually want to build a little film strip, or something you might see from a photo booth, like with a bunch of pictures. Gonna use subplot, but I don't know how many pictures I want ahead of time. So I'm going to use what's called Tiled Layout, and it'll allow you to add them.

    All right, so I can add another picture. And I will use the parent as the next tile. So we could do this all day, but you get the idea.

    And if I wanted this to look more like a photo booth output, I could actually remove some of this whitespace, right? So I can do this through the tiled layout. So I could remove our tile spacing and padding. So this gives you an idea of some of the options you have with Tiled Layout that are really, really helpful.

    Last but not least, I'm going to add a label. And notice that it actually spans both pictures. This is super, super helpful, again, for analyzing and labeling and visualizing all this kind of data, not just photo booth pictures like I've shown here.

    So what have we just seen? Some great stuff, actually. We looked at the webcam connectivity and then Tiled Layout-- super helpful. The new subplot and titles and labels across multiple axes.

    Very nice. I love how easy it is to connect MATLAB to webcams. In fact, MATLAB works with lots of hardware, not just webcams. I can go to the Add-ons menu in the tool strip, click down and say, Get Hardware Support Packages. And here I find literally hundreds of different options for extending MATLAB and Simulink to connect to hardware.

    So for instance, say I would like to work with my arduino board for fun projects on the weekend. I can click in and install. And it installs the support package, along with any necessary drivers that I need to get this up and running very quickly.

    Now, the window I'm in allows me to see hardware, but actually so much more than that. It's called the Add-On Explorer. And it gives access to all MathWorks add-on products. And just as importantly, to literally tens of thousands of community authored submissions, from toolboxes to apps to scripts and white papers.

    I can browse to find all these extensions to MATLAB, or examples of people solving problems that are interesting to me. So for instance, here I can drill down into what's available in the sciences. And we see a lot of the most popular submissions today are related to understanding the spread of COVID-19. I can drill down, learn more about any individual submission, see what's included in it, and then quickly add it to my MATLAB and it's ready to use right away.

    So what did we see here? We saw hardware support for MATLAB; the ability to connect MATLAB and Simulink to hundreds of types of different devices; and the Add-On Explorer for getting access to tens of thousands of community authored submissions, plus MathWorks add-on products. Really, the Add-On Explorer helps to answer the question, surely somebody else must have done this in MATLAB before me. Could I start from what they've done?

    Well, I think we've surpassed our goal of 21 features. So hopefully you're excited to get back and really start trying some of these things out. But you might be wondering if some of your code that you wrote a long time ago might work in MATLAB these days, in the latest and greatest.

    So I'll show you an example of some code I wrote back in grad school for classification of blood pressure information from MATLAB. So it shows an error that it is an unrecognized function or a variable treefit. And I can go straight to the line that is causing the error.

    And this is helping me via the code analyzer. And you can see some of the warnings and errors here on the right. And it will underline with a little squiggly anything. And you can see that, yes, sure enough, this has been removed. And it gives me an indication of what function to use.

    So when we're ready to go ahead and update, I can use what's called the Code Compatibility Report. And I'm running this on the entire directory. And it shows me any functions that might cause any issues, or are not recommended anymore. And then it also gives an indication of the line that it was occurring in, like we saw. And then the documentation links for how to change it and to help you out.

    So I went ahead and took a stab at changing this. And let's go ahead and look at some of the lines that I changed, or some of the code that I changed. So you can use the Code Comparison Report, and this gives a nice indication of each and every line that I changed and what it was changed to. So very, very helpful for updating, and for things like source control, and just looking at different versions of files.

    So let's take a look. We've looked at some great features for going ahead and updating with all these great features, like the Code Compatibility Report, the Comparison tool, and finally the Code Analyzer.

    Whew. I think we're just about done. Hopefully we've shown you plenty of features that you're excited to go out and try out right now. And hopefully we've piqued your curiosity so you want to learn what else is out there.

    You surely know about the release notes. And so you can always go to the release notes and figure out what's new in each release. Let's say you're moving from Release 2018a to Release 2020a, and you're really just interested in what's happening in graphics, because that's where you spend a lot of your time.

    It used to be that you would have to go, open the release notes for 18b. Then flip through and find the section on graphics. Then go to the release notes for 19a, find the section of graphics, et cetera. But we realized it's really common to try to focus-- that you want to focus your energy just on a specific section and specific set of releases. So we've made that way easier in the release notes.

    You can now go down and filter. So I say, only should to me the release notes for graphics, and only show me the release notes for the ranges I care about, let's say from 18b to 20a. And now I've built, effectively, my own little mini personal release notes that help focus me on just what I'm trying to do today.

    And so I think that's enough. That's 28 features you need now in MATLAB. Thanks very much. Have a great day.

    Download Code and Files

    Related Products

    Learn More