Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Matlab Release Notes

Download as pdf or txt
Download as pdf or txt
You are on page 1of 628

MATLAB® Release Notes

How to Contact MathWorks

Latest news: www.mathworks.com

Sales and services: www.mathworks.com/sales_and_services

User community: www.mathworks.com/matlabcentral

Technical support: www.mathworks.com/support/contact_us

Phone: 508-647-7000

The MathWorks, Inc.


1 Apple Hill Drive
Natick, MA 01760-2098
MATLAB® Release Notes
© COPYRIGHT 2004–2023 by The MathWorks, Inc.
The software described in this document is furnished under a license agreement. The software may be used or copied
only under the terms of the license agreement. No part of this manual may be photocopied or reproduced in any form
without prior written consent from The MathWorks, Inc.
FEDERAL ACQUISITION: This provision applies to all acquisitions of the Program and Documentation by, for, or through
the federal government of the United States. By accepting delivery of the Program or Documentation, the government
hereby agrees that this software or documentation qualifies as commercial computer software or commercial computer
software documentation as such terms are used or defined in FAR 12.212, DFARS Part 227.72, and DFARS 252.227-7014.
Accordingly, the terms and conditions of this Agreement and only those rights specified in this Agreement, shall pertain
to and govern the use, modification, reproduction, release, performance, display, and disclosure of the Program and
Documentation by the federal government (or other entity acquiring for or through the federal government) and shall
supersede any conflicting contractual terms or conditions. If this License fails to meet the government's needs or is
inconsistent in any respect with federal procurement law, the government agrees to return the Program and
Documentation, unused, to The MathWorks, Inc.
Trademarks
MATLAB and Simulink are registered trademarks of The MathWorks, Inc. See
www.mathworks.com/trademarks for a list of additional trademarks. Other product or brand names may be
trademarks or registered trademarks of their respective holders.
Patents
MathWorks products are protected by one or more U.S. patents. Please see www.mathworks.com/patents for
more information.
Contents

R2023b

Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2

Live Editor Tasks: Create Live Editor task from selected code with
interactive controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2
Live Editor Tables: Add tables containing text and images to live scripts and
functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2
Live Editor Controls: Add color pickers and state buttons to live scripts . . 1-2
Live Editor Controls: Select folders interactively in live scripts using file
browser . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-3
Live Editor Accessibility: Interact with inline output using the keyboard
...................................................... 1-3
Live Editor Export: Interactively customize export options, such as
document paper size, orientation, margins, and figure format . . . . . . . . 1-3
export Function: Convert live scripts and functions to Markdown files and
Jupyter notebooks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-4
Editor Execution: Run sections even if other sections contain syntax errors
...................................................... 1-4
Editor Variable Renaming: Automatically rename next references to
variables or functions in file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-4
Find and Replace Dialog Box: Use capture groups in regular expressions to
search for and replace groups of characters . . . . . . . . . . . . . . . . . . . . . 1-5
Debugging in MATLAB Online: Manage breakpoints and navigate the
function call stack using Debugger panel . . . . . . . . . . . . . . . . . . . . . . . 1-5
Desktop Layout in MATLAB Online: Open additional panels directly from
sidebars . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-6
Themes in MATLAB Online: Save color customizations for individual themes
...................................................... 1-6
Window Management in MATLAB Online: Automatically collapse windows
...................................................... 1-7
MATLAB on Macs: Better performance and improved battery life on
MacBooks with MATLAB and Simulink running natively on Apple silicon
...................................................... 1-7
MATLAB on Macs: Java Runtime Environment required for MATLAB and
MATLAB Runtime on Apple silicon . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-7
Functionality being removed or changed . . . . . . . . . . . . . . . . . . . . . . . . . 1-7

Language and Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-9

configureDictionary Function: Create dictionaries with configured keys and


values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-9
lookup, insert, and remove Functions: Find, add, and remove dictionary
entries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-9
codeIssues Object: Export issues identified in code . . . . . . . . . . . . . . . . . . 1-9
Code Compatibility Analyzer App: Group and filter code issues with
improved interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-9

iii
Class Diagram Viewer: Add known subclasses to diagrams . . . . . . . . . . . 1-10
mustBeSparse Function: Validate sparsity of arguments . . . . . . . . . . . . . 1-10
Functionality being removed or changed . . . . . . . . . . . . . . . . . . . . . . . . 1-11

Data Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-13

Experiment Manager App: Design experiments to run MATLAB code, and


visualize, filter, and compare results . . . . . . . . . . . . . . . . . . . . . . . . . . 1-13
Pivot Table Live Editor Task: Interactively summarize tabular data in
pivoted table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-13
resize, paddata, and trimdata Functions: Change the size of data by adding
or removing elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-13
smoothdata2 Function: Smooth noisy data in two dimensions . . . . . . . . . 1-14
kde Function: Estimate a probability function by using kernel density
estimation for univariate data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-14
Join Tables Live Editor Task: Sort output timetable by row times when row
times are not key values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-14
Data Cleaning: Interactively fill missing data with values from nearest
neighbor rows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-14
Live Editor: Display the contents of nested tables as variables . . . . . . . . 1-14
Live Editor: Copy output data as tab-delimited text . . . . . . . . . . . . . . . . . 1-15
pivot Function: Display empty groups in pivoted table . . . . . . . . . . . . . . 1-15
pivot Function: Specify row names for pivoted table as row group names
..................................................... 1-15
stackedplot Function: Plot events associated with timetables . . . . . . . . . 1-15
Timetable Events: Perform calculations directly on event tables without
extracting their data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-16
containsrange, overlapsrange, and withinrange Functions: Specify time
ranges by using event filters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-16
Variables Editor in MATLAB Online: Interactively change display format for
datetime or duration data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-16
Variables Editor in MATLAB Online: View and interactively edit scalar
structures, object arrays, and tables with grouped variables . . . . . . . . 1-17
Accessibility in MATLAB Online: Use a screen reader to interact with the
Workspace browser, Variables editor, Property Inspector, and Import Tool
..................................................... 1-18
Histogram Distribution Charts: Calculate values and create histograms
using percentages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-18
tallrng Function: Specify random number algorithm without specifying seed
..................................................... 1-18
Functionality being removed or changed . . . . . . . . . . . . . . . . . . . . . . . . 1-18

Data Import and Export . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-20

readstruct Function: Read data from JSON files . . . . . . . . . . . . . . . . . . . 1-20


writestruct Function: Write structure arrays to JSON files . . . . . . . . . . . 1-20
Parquet: Create ParquetDatastore objects more efficiently with partition
control in parallel environments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-20
cmdsep Function: Return command separator for current platform . . . . . 1-20
NetCDF Interface: Import netCDF data using Import Tool in MATLAB Online
and Import Data Live Editor Task . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-20
NetCDF Interface in MATLAB Online: Import netCDF data by double-
clicking netCDF files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-20
Image File Format Libraries: LibTIFF library upgraded to version 4.5.0 . 1-20
Scientific File Format Libraries: HDF4 library upgraded to version 4.2.16
..................................................... 1-21

iv Contents
Scientific File Format Libraries: HDF5 library upgraded to version 1.10.10
..................................................... 1-21
Scientific File Format Libraries: NetCDF library upgraded to version 4.9.1
..................................................... 1-21
serialbreak Function: Send break to device connected to serial port . . . . 1-21
Functionality being removed or changed . . . . . . . . . . . . . . . . . . . . . . . . 1-21

Mathematics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-23

Ordinary Differential Equations: Use object-oriented solution framework for


ODEs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-23
rng Function: Change default algorithm and seed for random number
generator, and specify random number algorithm without specifying seed
..................................................... 1-23
MATLAB Support Package for Quantum Computing: Solve Quadratic
Unconstrained Binary Optimization (QUBO) problems . . . . . . . . . . . . 1-24
MATLAB Support Package for Quantum Computing: Control circuit plot
appearance and behavior with QuantumCircuitChart objects . . . . . . . 1-24
deconv Function: Perform least-squares deconvolution with different
convolved subsections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-24
svdappend Function: Calculate revised singular value decompositions . . 1-25
expmv Function: Calculate matrix exponential multiplied by vector . . . . 1-25
expm Function: Improved algorithm for single-precision matrices . . . . . . 1-25
scatteredInterpolant Object: Use multivalued interpolation to interpolate
multiple data sets simultaneously . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-25

Graphics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-26

piechart and donutchart Functions: Create configurable, interactive pie and


donut charts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-26
Plot Colors: Choose from nine color palettes . . . . . . . . . . . . . . . . . . . . . . 1-26
abyss Function: Apply blue-to-black colormap to charts and images . . . . 1-27
Legend: Control the order of legend entries . . . . . . . . . . . . . . . . . . . . . . 1-27
xscale, yscale, and zscale Functions: Quickly change between logarithmic
and linear axes scales after plotting . . . . . . . . . . . . . . . . . . . . . . . . . . 1-28
xsecondarylabel, ysecondarylabel, and zsecondarylabel Functions: Create,
delete, or modify secondary axis labels . . . . . . . . . . . . . . . . . . . . . . . . 1-28
Bar Charts: Specify bar labels as string vectors . . . . . . . . . . . . . . . . . . . 1-29
xregion and yregion Functions: Create unbounded regions and specify
multiple regions as matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-29
Text Objects: Control whether text labels are included in axes limits . . . . 1-30
Contour Plots: Customize colors of contour labels . . . . . . . . . . . . . . . . . . 1-31
Colors and Line Styles: Control automatic color and line style selection for
additional chart objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-31
Heatmap Charts: Control text interpreter for text labels in heatmap charts
..................................................... 1-32
Images: Display images with datetime, duration, or categorical pixel
coordinates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-33
swarmchart Function: Create horizontal swarm charts . . . . . . . . . . . . . . 1-33
Geographic Plots: Some basemaps have improved appearance at high zoom
levels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-34
Figure Code in MATLAB Online: Generate code from Camera tab . . . . . . 1-35
Figure Code in MATLAB Online: Generate code from Property Inspector
..................................................... 1-35
Functionality being removed or changed . . . . . . . . . . . . . . . . . . . . . . . . 1-35

v
App Building . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-41

uislider Function: Create slider to specify range of values in apps and on


App Designer canvas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-41
uicontextmenu and uimenu Functions: Access information about action used
to open context menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-41
uispinner and uieditfield Functions: Create spinners and numeric edit fields
with placeholder text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-41
uilistbox and uidropdown Functions: Access index of component value in list
of items . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-42
uitable Function: Query selected table data in current table display . . . . 1-42
uicontextmenu Function: Context menus on trees appear when you right-
click anywhere in the tree . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-42
appmigration.migrateGUIDEApp Function: Migrating multiple apps from
GUIDE to App Designer updates app references . . . . . . . . . . . . . . . . . 1-43
App Designer: Interactively rearrange tabs, menus, tree nodes, and toolbar
tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-43
App Designer: Write unit tests for custom UI components . . . . . . . . . . . . 1-44
App Designer: View changes to HTML UI component source while working
in Design View . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-45
Comparison Tool: Save app comparison results as PDF or DOCX reports
programmatically and interactively . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-45
Axes Interactions: Interpolate data tip location . . . . . . . . . . . . . . . . . . . . 1-45
Axes Interactions: Indicate azimuth and elevation angles . . . . . . . . . . . . 1-45
Axes Interactions: Zoom into rectangular region of 2-D view of 3-D chart
..................................................... 1-45
App Testing Framework: Automatically scroll to components outside
viewable area . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-46
Web Apps and Standalone Applications: Data brushing supported in
graphics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-46

Performance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-47

Language and Programming: Improved performance for reading and


writing class property values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-47
dde23 Function: Improved performance integrating high-dimensional
systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-47
nufftn Function: Improved performance with nonuniform sample points or
query points . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-48
fillmissing Function: Improved performance when filling entries with
previous or next numeric value . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-49
ismember Function: Improved performance with small unsorted set array
..................................................... 1-49
islocalmax and islocalmin Functions: Improved performance when finding
local minima and maxima . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-50
Data Cleaner App: Improved rendering performance of Cleaning Parameters
panel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-50
Tiled Chart Layouts: Improved performance for flow layouts with spanned
axes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-51
Plots in Apps: Improved performance when scrolling to zoom . . . . . . . . . 1-52
Plots in Apps: Improved responsiveness for scatter plot interactions in apps
..................................................... 1-52
Plots in Apps: Constant lines and constant regions update continuously as
you pan . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-53
App Building: Improved performance when resizing apps with nested
containers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-54

vi Contents
App Building: Improved startup performance for apps with panels in
multiple tabs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-55
App Designer: Improved app loading and running performance . . . . . . . 1-56
App Designer: Improved performance when adding custom UI components
to an app . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-57
Property Inspector in MATLAB Online: Improved performance when
opening for the first time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-57
Graphics in MATLAB Online: Images and 3-D plots in apps have significant
performance gains . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-57

Software Development Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-59

Source Control API: Interact with Git source control programmatically . . 1-59
Project API: Determine whether file belongs to a project . . . . . . . . . . . . . 1-59
Source Control in MATLAB Online: Perform source control operations using
unified panel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-59
Source Control in MATLAB Online: Expanded support for Git workflows
..................................................... 1-60
Projects in MATLAB Online: Added support for team collaboration
workflows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-61
Project Examples: Identify and run tests in projects . . . . . . . . . . . . . . . . 1-61
Build Automation: Use built-in tasks to define common build actions . . . . 1-61
Build Automation: Automatically open MATLAB project when running builds
..................................................... 1-61
Build Automation: Invoke build tool from project subfolders . . . . . . . . . . 1-61
Build Automation: Operate on file collections . . . . . . . . . . . . . . . . . . . . . 1-61
Build Automation: Name the inputs and outputs of tasks for incremental
builds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-62
Build Automation: Run tasks using build options . . . . . . . . . . . . . . . . . . . 1-62
Unit Testing Framework: Programmatically access code coverage results
using the runtests function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-62
Unit Testing Framework: Test for missing elements . . . . . . . . . . . . . . . . 1-62
Unit Testing Framework: Modify test report title . . . . . . . . . . . . . . . . . . 1-62
App Testing Framework: Automatically scroll to components outside
viewable area . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-63
matlab.test.behavior.Missing Class: Test against constructor arguments that
result in incompatible values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-63
Functionality being removed or changed . . . . . . . . . . . . . . . . . . . . . . . . 1-63

External Language Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-64

Call MATLAB from C++: Generate output types for strongly typed methods
and functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-64
Publish C++ Interface: Support for pointer return of string and
fundamental types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-64
Call MATLAB from .NET: Generate C# code interface for MATLAB
packages, classes, and functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-64
Call .NET from MATLAB: Create explicit interface view of .NET object . . 1-64
Python: Support for version 3.11 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-64
Python Interface: Use of environment variable PYTHONHOME to load
interpreter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-64
Python Interface: Convert list and tuple of Python datetime or timedelta
objects to MATLAB arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-65
Python Interface: Resolve Python configuration issues . . . . . . . . . . . . . . 1-65
Compilers: Download MinGW-w64 8.1 from Add-On Explorer . . . . . . . . . 1-65
Compilers: Support for NAG Fortran on Apple silicon . . . . . . . . . . . . . . . 1-65

vii
Compilers: Support for Microsoft Visual Studio Build Tools . . . . . . . . . . . 1-65
Functionality being removed or changed . . . . . . . . . . . . . . . . . . . . . . . . 1-66

Hardware Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-67

Support for ArduCam Multi Camera Adapter Module on Raspberry Pi


Hardware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-67

R2023a

Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-2

MATLAB Install: Reduce footprint using default installation without local


documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-2
Editor: Interactively increment numeric values within section and run
section after every change . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-2
Live Editor Controls: Add file browser to select file interactively in live
script . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-2
Live Editor Controls: Align controls within a section when code is hidden
...................................................... 2-3
Desktop Layout in MATLAB Online: Access desktop tools and change the
desktop layout using sidebars . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-3
Code Issues Tool in MATLAB Online: Check code for errors and warnings
using Code Issues tool . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-4
Find Files Tool in MATLAB Online: Search for files with improved Find Files
tool . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-5
Editor in MATLAB Online: Edit read-only files . . . . . . . . . . . . . . . . . . . . . . 2-6
Search in MATLAB Online: Access videos using Search box . . . . . . . . . . . 2-6
System Command Functions: Set and get multiple variables using operating
system commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-6
loadenv Function: Load environment variables from .env and plain text files
...................................................... 2-6
Comparison Tool: Save text comparison results as PDF or DOCX reports
programmatically and interactively . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-6
Toolbox Packaging: Specify packaging options when creating custom
toolbox programmatically . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-7
Functionality being removed or changed . . . . . . . . . . . . . . . . . . . . . . . . . 2-7

Language and Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-8

Code Analyzer: Enable custom checks and configure existing checks . . . . 2-8
fix Function: Fix code issues from the command line . . . . . . . . . . . . . . . . . 2-8
Code Analyzer App: Apply fixes to code issues interactively . . . . . . . . . . . 2-9
dictionary Object: Access and assign dictionary cell values with curly braces
...................................................... 2-9
Output Argument Validation: Debug within output argument blocks . . . . 2-10
Functionality being removed or changed . . . . . . . . . . . . . . . . . . . . . . . . 2-10

Data Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-12

pivot Function: Summarize tabular data using pivot table . . . . . . . . . . . . 2-12

viii Contents
table and timetable Data Types: Perform calculations directly on tables and
timetables without extracting their data . . . . . . . . . . . . . . . . . . . . . . . 2-12
Timetable Events: Find and label events in timetables using attached event
tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-12
combinations Function: Generate all element combinations of arrays . . . 2-12
fillmissing2 Function: Fill missing entries in two-dimensional data . . . . . 2-13
fillmissing Function: Use values from nearest neighbors to fill missing data
..................................................... 2-13
Descriptive Statistics and Arithmetic: Omit or include missing data of
multiple data types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-13
Find and Remove Trends Live Editor Task: Interactively find and remove
periodic and polynomial trends . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-13
Data Cleaner App: Save session as MAT-file and reload session . . . . . . . . 2-14
head and tail Functions: Get top or bottom rows of array . . . . . . . . . . . . 2-14
groupsummary Function: Compute number of unique elements . . . . . . . 2-14
movevars Function: Move table variables after last variable without After
name-value argument . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-14
rowfun and varfun Functions: OutputFormat name-value argument can take
"auto" as value . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-15
day Function: Return ISO day of week . . . . . . . . . . . . . . . . . . . . . . . . . . 2-15
week Function: Return ISO week of year or week of month . . . . . . . . . . . 2-15
Variables Editor: Edit categories of categorical table variable in MATLAB
Online . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-16

Data Import and Export . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-17

Import Data Live Editor Task: Import data in live scripts . . . . . . . . . . . . . 2-17
audiowrite Function: Write MP3 audio files . . . . . . . . . . . . . . . . . . . . . . . 2-17
imfinfo Function: Get information about XMP metadata embedded in JPEG
files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-17
Parallel Processing: Use readtable in thread-based environments . . . . . . 2-17
Scientific File Format Libraries: CDF library upgraded to version 3.8.1 . . 2-17
Scientific File Format Libraries: CFITSIO library upgraded to version 4.1.0
..................................................... 2-17
Functionality being removed or changed . . . . . . . . . . . . . . . . . . . . . . . . 2-18

Mathematics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-19

MATLAB Support Package for Quantum Computing: Build, simulate, and


run quantum algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-19
pageeig Function: Perform eigenvalue decomposition on pages of N-D
arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-19
randi Function: Create random logical array . . . . . . . . . . . . . . . . . . . . . . 2-19
Functionality being removed or changed . . . . . . . . . . . . . . . . . . . . . . . . 2-20

Graphics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-21

xregion and yregion Functions: Highlight horizontal or vertical regions of


plots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-21
sky Function: Apply monochromatic colormap to charts . . . . . . . . . . . . . 2-21
tiledlayout Function: Create horizontal or vertical layouts . . . . . . . . . . . 2-22
animatedline Function: Create animated lines using numeric, datetime, or
duration data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-22
Grid Lines: Customize grid line thickness . . . . . . . . . . . . . . . . . . . . . . . . 2-22
Axes Labels: Rotate x- and y-axes labels without overlapping the axes . . 2-23
Plotting Series of Lines: Control cycling order of line styles . . . . . . . . . . 2-24

ix
Plotting Series of Lines: Control whether the data range of a line affects
automatic axes limits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-24
fontsize and fontname Functions: Optionally specify the object containing
the text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-25
DatetimeRuler Object: Set or get the reference date for plotting datetime
values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-25
Image Display Preferences: Access and update imshow preferences in
MATLAB Online . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-25
Functionality being removed or changed . . . . . . . . . . . . . . . . . . . . . . . . 2-26

App Building . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-27

addStyle Function: Add styles to items in list box or drop-down UI


component . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-27
uistack Function: Change stacking order of UI components in UI figure . 2-27
uipanel and uibuttongroup Functions: Specify container border color . . . 2-27
uihtml Function: Send events between MATLAB and HTML . . . . . . . . . . 2-27
uiimage Function: Specify image alt text for use with screen readers . . . 2-28
appmigration.migrateGUIDEApp Function: Programmatically migrate
existing GUIDE apps to App Designer . . . . . . . . . . . . . . . . . . . . . . . . . 2-28
App Designer: View progress when loading an app . . . . . . . . . . . . . . . . . 2-28
App Designer: Add label to unlabeled UI component . . . . . . . . . . . . . . . . 2-28
App Designer: Replace assigned callback with new callback . . . . . . . . . . 2-28
App Testing Framework: Test context menus within labels . . . . . . . . . . . 2-29
Axes Interactions: Customize behavior of interactions with axes view . . . 2-29
Plots in Apps: Enable data cursor mode . . . . . . . . . . . . . . . . . . . . . . . . . 2-29
Plots in Apps: Specify axes for interaction mode . . . . . . . . . . . . . . . . . . . 2-30
Functionality being removed or changed . . . . . . . . . . . . . . . . . . . . . . . . 2-30

Performance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-32

Language and Programming: Improved performance when calling functions


and methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-32
Function Handles: Improved performance when invoking handles to named
functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-32
varargin Argument: Improved performance when specifying zero or more
inputs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-33
timetable Data Type Indexing: Improved performance when subscripting
with times or with withtol subscript . . . . . . . . . . . . . . . . . . . . . . . . . . 2-34
Complex Matrices: Improved performance when using colon indexing to
copy complex matrices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-35
mean, std, var, and rmse Functions: Improved performance when computing
along default vector dimension . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-37
Moving Statistics Functions: Improved performance when computing over
matrix with sample points . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-37
histcounts Function: Improved performance with small numeric and logical
input data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-38
fzero function: Improved performance . . . . . . . . . . . . . . . . . . . . . . . . . . 2-38
Plots in Apps: Improved performance when rerendering axes . . . . . . . . . 2-39
Plots in Apps: Improved performance when creating axes . . . . . . . . . . . . 2-39
Plots in Apps: Improved responsiveness of ruler-pan interaction . . . . . . . 2-40
Live Editor: Improved performance when filtering numeric table variables
..................................................... 2-41
Property Inspector: Improved performance when opening for the first time
..................................................... 2-41

x Contents
Property Inspector: Improved performance when switching between objects
..................................................... 2-42
Variables Editor: Improved performance of cell editing in MATLAB Online
..................................................... 2-42
Variables Editor: Improved speed of data display when scrolling in MATLAB
Online . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-43
App Building: Improved app startup performance . . . . . . . . . . . . . . . . . . 2-43
App Building: Improved startup performance for apps with multiple tabs
..................................................... 2-44
App Building: Improved performance when resizing some apps . . . . . . . 2-45

Software Development Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-47

Build Automation: Improve build speed and efficiency with incremental


builds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-47
Build Automation: Create and run tasks that accept arguments . . . . . . . 2-47
Dependency Analyzer: Analyze files and folders with or without a project
..................................................... 2-47
Project Preferences: Recreate empty project folders in Git repositories . . 2-47
Project API: Determine if file is under project root folder . . . . . . . . . . . . 2-47
Project API: Export subset of project files to archive . . . . . . . . . . . . . . . . 2-47
Project Sharing: Include only specific files in project archive using export
profile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-48
Comparison Tool: Automate comparison report generation for continuous
integration (CI) workflows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-48
Source Control in MATLAB Online: Save uncommitted changes by creating
a Git stash . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-48
Source Control in MATLAB Online: Manage Git remote repositories locally
using Branch Manager . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-48
Source Control in MATLAB Online: Detect and extract conflict markers from
text and binary files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-48
Comparison Tool in MATLAB Online: Compare project definition files . . . 2-48
Dependency Analyzer in MATLAB Online: Investigate circular dependencies
using the Project Hierarchy view . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-49
Unit Testing Framework: Run tests interactively by using Test Browser . 2-49
Unit Testing Framework: Programmatically access code coverage results
..................................................... 2-50
Unit Testing Framework: Temporarily set environment variables . . . . . . 2-50
Unit Testing Framework: Test for handle validity . . . . . . . . . . . . . . . . . . 2-50
Unit Testing Framework: Write text to files in thread-based environment
..................................................... 2-50
Unit Testing Framework: Use renamed classes in testing and other
automated workflows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-50
App Testing Framework: Test context menus within labels . . . . . . . . . . . 2-51
Performance Testing Framework: Use fewer samples to meet the objective
margin of error . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-51
Functionality being removed or changed . . . . . . . . . . . . . . . . . . . . . . . . 2-52

External Language Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-53

Publish C++ Interface: Publish interface for C++ library in Live Editor . 2-53
Interface to C++ Library: Execute C++ library functions out-of-process
..................................................... 2-53
Interface to C++ Library: Support for default arguments . . . . . . . . . . . . 2-53
Interface to C++ Library: Support for comments in function templates . . 2-53
Publish C++ Interface: Put libraries on run-time path . . . . . . . . . . . . . . . 2-53

xi
Publish C++ Interface: Resolve multiple redefinition and unresolved
external symbol errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-54
Publish C++ Interface: Information to debug C++ library functions . . . . 2-54
Publish C++ Interface: Support for MATLAB operators for C++ methods
..................................................... 2-54
Java Interface: Support for Java 11 JDK and JRE . . . . . . . . . . . . . . . . . . . 2-54
Java Interface: jenv and matlab_jenv provide environment information . . 2-54
Python Interface: Convert between MATLAB datetime and Python datetime,
NumPy datetime64 types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-54
Python Interface: Convert between MATLAB duration and Python timedelta,
NumPy timedelta64 types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-55
Python Objects: Use Python objects as keys in dictionary . . . . . . . . . . . . 2-55
.NET Interface: Convert between MATLAB dictionary and .NET
System.Collections.Generic.Dictionary objects . . . . . . . . . . . . . . . . . . 2-55
.NET Objects: Use .NET objects as keys in dictionary . . . . . . . . . . . . . . . 2-55
.NET Engine: Support for MATLAB structs . . . . . . . . . . . . . . . . . . . . . . . 2-55
Perl 5.36.0: MATLAB support on Windows . . . . . . . . . . . . . . . . . . . . . . . 2-55
Compiler support changed for building C and C++ interfaces, MEX files,
and standalone MATLAB engine and MAT-file applications . . . . . . . . . 2-56
Functionality being removed or changed . . . . . . . . . . . . . . . . . . . . . . . . 2-56

Hardware Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-58

Support for MJPEG format in USB Webcams on Windows . . . . . . . . . . . . 2-58


Support for 32-bit Debian Bullseye on Raspberry Pi . . . . . . . . . . . . . . . . 2-58
Support for Raspberry Pi Zero 2 W and Raspberry Pi Compute Module 4
..................................................... 2-58

R2022b

Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-2

Live Editor Controls: Add numeric spinners to increment and decrement


variable values in live scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-2
Live Editor Tasks: Specify what code to run when control value changes
...................................................... 3-2
Suggestions and Completions: Change when to show suggestions and how
to accept them . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-2
Search in MATLAB Online: Access toolstrip actions, preferences, and Help
Center resources using search . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-3
System Theme in MATLAB Online: Change colors of MATLAB desktop to
match operating system color scheme . . . . . . . . . . . . . . . . . . . . . . . . . . 3-5
Help Center: View documentation for all products and determine which
products are installed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-5
unsetenv Function: Remove environment variable . . . . . . . . . . . . . . . . . . 3-6
isenv Function: Determine if environment variable exists . . . . . . . . . . . . . 3-6
Comparison Tool: Compare MAT files, FIG files, live scripts, and live
functions in MATLAB Online . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-6
Functionality being removed or changed . . . . . . . . . . . . . . . . . . . . . . . . . 3-6

Language and Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-8

xii Contents
dictionary Object: Map unique keys to values for fast lookup . . . . . . . . . . 3-8
Output Argument Validation: Validate output arguments in functions and
class methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-8
Code Analyzer App: Identify code issues . . . . . . . . . . . . . . . . . . . . . . . . . . 3-9
codeIssues Object: Identify and store code issues from one or more files
...................................................... 3-9
Custom Compact Display: Live Editor, Variables editor, and Workspace
browser follow CustomCompactDisplayProvider implementations . . . . . 3-9
Customized Dot Indexing: New methods handle parentheses-dot
combinations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-9
Functionality being removed or changed . . . . . . . . . . . . . . . . . . . . . . . . . 3-9

Data Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-11

Data Cleaner App: Clean data in table . . . . . . . . . . . . . . . . . . . . . . . . . . 3-11


Data Cleaner App: View sparklines and summary statistics . . . . . . . . . . . 3-11
stackedplot Function: Plot data from multiple tables or timetables . . . . . 3-11
detrend Function: Detrend tabular data . . . . . . . . . . . . . . . . . . . . . . . . . 3-12
rmoutliers Function: Define outlier locations, and optionally return outlier
indicator, thresholds, and center value . . . . . . . . . . . . . . . . . . . . . . . . 3-12
mape and rmse Functions: Calculate error between forecast and actual data
..................................................... 3-12
isuniform Function: Determine if vector is uniformly spaced . . . . . . . . . . 3-12
Serial date numbers and date strings are not recommended . . . . . . . . . . 3-12
datetime and convertTo Functions: Convert between CDF TT2000 times and
datetime arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-13
Data Preprocessing Live Editor Tasks: Plot multiple table variables . . . . 3-13
Data Preprocessing Live Editor Tasks: Append cleaned table variables and
specify logical tabular output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-14
Clean Missing Data Live Editor Task: Plot nonnumeric table data, specify
minimum number of missing entries, and use custom fill method . . . . 3-14
Clean Outlier Data Live Editor Task: Convert outliers to missing . . . . . . . 3-14
Live Editor and Variables Editor: Control placement of missing values when
sorting numeric data in MATLAB Online . . . . . . . . . . . . . . . . . . . . . . . 3-15
Variables Editor: View sparklines and summary statistics for tabular data in
MATLAB Online . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-15
Variables Editor: Navigate variable with Find and Go To dialog boxes in
MATLAB Online . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-15
Variables Editor: Interactively save logical indices of data selection in
MATLAB Online . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-16
Variables Editor: Replace tabular data with empty arrays in MATLAB Online
..................................................... 3-16
Functionality being removed or changed . . . . . . . . . . . . . . . . . . . . . . . . 3-16

Data Import and Export . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-22

Parquet: Use Parquet files containing nested structured data . . . . . . . . . 3-22


SequentialDatastore Object: Sequentially read data from multiple
datastores . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-22
Datastores: Create subsets of arbitrarily nested transformations and
combinations of datastores . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-22
Parallel Processing: Use low-level file I/O operations in thread-based
environments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-22
CDF Interface: Read CDF_INT8 and CDF_TIME_TT2000 data . . . . . . . . . 3-22
imwrite Function: Use datetime values to write metadata for PNG images
..................................................... 3-23

xiii
Image File Format Libraries: LibTIFF library upgraded to version 4.4.0 . 3-23
Scientific File Format Libraries: HDF4 and HDF-EOS2 libraries are
upgraded . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-23
Functionality being removed or changed . . . . . . . . . . . . . . . . . . . . . . . . 3-23

Mathematics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-24

pagenorm Function: Calculate norms using pages of N-D arrays . . . . . . . 3-24


Functionality being removed or changed . . . . . . . . . . . . . . . . . . . . . . . . 3-24

Graphics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-25

Plotting Table Data: Create stem, stairstep, and geographic plots by passing
tables directly to plotting functions . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-25
errorbar Function: Plot multiple lines with error bars at once . . . . . . . . . 3-25
tightPosition Function: Get the location and size of axes plotting area . . . 3-26
tilenum and tilerowcol Functions: Convert between rows and columns and
tile numbers in tiled chart layouts . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-26
Tiled Chart Layout: Define GridSizeChangedFcn callback that executes
when the grid size changes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-26
Contour Plots: Customize contour labels, colors, and transparency . . . . . 3-26
boxchart Function: Specify the box edge color and box median line color
..................................................... 3-27
3-D Stem and Bar Plots: Expanded data type support . . . . . . . . . . . . . . . 3-28
Image Objects: Control the maximum resolution for displaying images . . 3-28
Figure Code: Generate code for figure formatting in MATLAB Online . . . 3-28
Plot Options: Customize figure creation, data linking, and labeling in
MATLAB Online . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-29
Functionality being removed or changed . . . . . . . . . . . . . . . . . . . . . . . . 3-29

App Building . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-34

ClickedFcn and DoubleClickedFcn Callbacks: Program a response to a user


clicking or double-clicking a tree, check box tree, list box, table, or drop-
down component . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-34
uieditfield Function: Specify valid length and input type for edit field text
..................................................... 3-34
uiimage Function: Create an image hyperlink . . . . . . . . . . . . . . . . . . . . . 3-34
uipanel and uibuttongroup Functions: Specify container border width . . 3-34
uigridlayout Function: Query grid layout manager size and location . . . . 3-35
uibutton and uitogglebutton Functions: Specify additional icon and icon
alignment options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-35
uitoolbar Function: Specify background color of toolbar . . . . . . . . . . . . . 3-35
scroll Function: Programmatically scroll to specified component in container
..................................................... 3-35
isInScrollView Function: Determine if any component in a container is
visible, not only direct children . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-35
App Designer: Add and delete callbacks more efficiently . . . . . . . . . . . . . 3-35
App Designer: Move components between tabs . . . . . . . . . . . . . . . . . . . . 3-36
Graphics Support: Restore axes view and display context menu for
interaction modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-36
Graphics Support: Use visual camera toolbar interface . . . . . . . . . . . . . . 3-36
Comparison Tool: Toggle the ability to navigate only mergeable changes
..................................................... 3-36
Functionality being removed or changed . . . . . . . . . . . . . . . . . . . . . . . . 3-36

xiv Contents
Performance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-40

prctile, quantile, and iqr Functions: Improved performance with small input
data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-40
mldivide and pagemldivide Functions: Improved performance with small
matrices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-40
conv, conv2, and convn Functions: Improved performance when convolving
two vectors, matrices, and arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-41
Tall Arrays: Improved performance when indexing tall arrays backed by
parquetDatastore . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-42
App Building: Improved app startup performance . . . . . . . . . . . . . . . . . . 3-43
App Building: Improved startup performance for apps with multiple tabs
..................................................... 3-43
Plots in Apps: Improved responsiveness when interacting with large images
..................................................... 3-44
Plots in Apps: Ticks and grid lines update as you pan . . . . . . . . . . . . . . . 3-45
Plots in Apps: Improved performance and smaller PDF files when exporting
complex plots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-46
Tiled Chart Layouts: Improved performance for flow layouts with spanned
axes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-47
ArrayDatastore Object: Improved performance when reading data using
readall . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-48
ArrayDatastore Object: Improved performance when specifying number of
rows to read . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-49
parquetread Function: Improved performance reading string data from
Parquet files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-49
parquetDatastore Function: Improved performance when creating datastore
with large number of Parquet files . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-50
Workspace Browser: Improved performance of variable-deletion dialog
boxes in MATLAB Online . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-50
Variables Editor and Live Editor: Improved speed of data display when
scrolling in MATLAB Online . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-50
lookfor Function: Improved performance when searching . . . . . . . . . . . . 3-51

Software Development Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-52

Build Tool: Create and run software-build tasks . . . . . . . . . . . . . . . . . . . 3-52


Dependency Analyzer: New warnings to identify problems . . . . . . . . . . . 3-52
Project API: Extract project from archive . . . . . . . . . . . . . . . . . . . . . . . . 3-52
Source Control in MATLAB Online: Manage Git branches and repositories
..................................................... 3-52
Unit Testing Framework: Add methods and properties to test classes
interactively . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-52
Unit Testing Framework: Specify action to take against invalid test files
..................................................... 3-52
Unit Testing Framework: Generate descriptive test parameter names using
cell arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-53
Unit Testing Framework: Compare dictionaries in tests . . . . . . . . . . . . . 3-54
Functionality being removed or changed . . . . . . . . . . . . . . . . . . . . . . . . 3-54

External Language Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-56

.NET Interface: Support for .NET 5 and .NET Core . . . . . . . . . . . . . . . . . 3-56


.NET Engine API: Call MATLAB from .NET applications . . . . . . . . . . . . . 3-56
Publish C++ Interface: Support for char* output as nullTerminated string
..................................................... 3-56

xv
Call MATLAB from C++: Use MATLAB enumeration classes in strongly-
typed interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-56
Python Interface: Display keyword (key-value pair) arguments created by
pyargs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-56
Python Interface: Convert scalar logical and numeric Python types to
MATLAB types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-57
Python Engine: Pass NumPy arrays directly to MATLAB functions . . . . . . 3-57
Python Engine: Install MATLAB Engine API with pip Command . . . . . . . 3-57
Python: Support for Version 3.10 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-58
Functionality being removed or changed . . . . . . . . . . . . . . . . . . . . . . . . 3-58

Hardware Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-59

Upload Libraries and Configure Pins for I2C, SPI, and Serial Communication
Using the Arduino Explorer App . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-59
Support for servo and rotary encoder peripherals connected to Arduino-
compatible ESP32 boards . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-59

R2022a

Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-2

Themes in MATLAB Online: Change the colors of the MATLAB desktop by


selecting a dark or light theme . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-2
Live Editor Colors: Change the text and background colors of live scripts
and functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-3
Live Editor Hyperlinks: Insert hyperlinks to specific locations in separate
live scripts or live functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-3
Live Editor Export: Export live scripts and functions programmatically using
the export function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-3
Live Editor Accessibility: Interact with output in live scripts using the
keyboard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-3
Live Editor Tasks: View and interact with tasks when code is hidden . . . . . 4-4
Component Browser: Reorder children in App Designer or the Property
Inspector . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-4
Editor Python Support: View and edit Python files with syntax highlighting,
auto-indenting, and delimiter matching . . . . . . . . . . . . . . . . . . . . . . . . . 4-4
Find and Replace Dialog Box: Search text in the Editor and Live Editor
using regular expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-4
Profiler: Access the Profiler from the Apps tab . . . . . . . . . . . . . . . . . . . . . 4-5
Internationalization: UTF-8 system encoding on Windows platforms . . . . . 4-5
Installation Settings: Configure persistent settings for MATLAB installations
...................................................... 4-5
Comparison Tool: Save results as HTML report . . . . . . . . . . . . . . . . . . . . . 4-5
Comparison Tool: Compare folders in MATLAB Online . . . . . . . . . . . . . . . 4-5
MATLAB Drive: macOS 10.15 Catalina will no longer receive updates to
MATLAB Drive Connector (April 2022) . . . . . . . . . . . . . . . . . . . . . . . . . 4-6
Functionality being removed or changed . . . . . . . . . . . . . . . . . . . . . . . . . 4-6

Language and Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-7

xvi Contents
Class Introspection: Description and DetailedDescription properties of
metaclasses contain text from code comments . . . . . . . . . . . . . . . . . . . 4-7
Class Introspection: Access class aliases from meta.class instance . . . . . . 4-7
Background Pool: See futures in the background . . . . . . . . . . . . . . . . . . . 4-7
cancelAll Method: Cancel currently queued and running futures in the
background pool . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-7
Background Pool: Check the status of the background pool . . . . . . . . . . . . 4-7
pcode Function: Create P-code files with enhanced obfuscation . . . . . . . . 4-7
str2num Function: Restrict evaluation to basic math expressions . . . . . . . 4-8
assert Function: Output displays which assertion threw an error and the
location in the code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-8
Functionality being removed or changed . . . . . . . . . . . . . . . . . . . . . . . . . 4-8

Data Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-10

Data Cleaner App: Interactively preprocess and organize column-oriented


data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-10
allfinite, anynan, and anymissing Functions: Determine if all array elements
are finite, any element is NaN, and any element is missing . . . . . . . . . 4-10
quantile, prctile, and iqr Functions: Calculate quantiles, percentiles, and
interquartile range . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-10
rms Function: Calculate root-mean-square value . . . . . . . . . . . . . . . . . . . 4-10
std and var Functions: Optionally return mean as a second output . . . . . 4-11
Date and Time Functions: Some Financial Toolbox functions combined with
MATLAB functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-11
Date and Time Functions: Some Financial Toolbox functions moved to
MATLAB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-12
matlab.datetime.compatibility.convertDatenum Function: Convert text
timestamps and serial date numbers to datetime values in a backward-
compatible way . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-13
categorical Data Type: Use a pattern object to specify category names that
match a pattern . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-13
table and timetable Data Types: Use a pattern object to specify row,
variable, and property names that match a pattern . . . . . . . . . . . . . . . 4-14
Data Preprocessing Functions: Append transformed variables to input data
using the ReplaceValues name-value argument . . . . . . . . . . . . . . . . . . 4-15
Data Preprocessing Functions: Return table with logical values using the
OutputFormat name-value argument . . . . . . . . . . . . . . . . . . . . . . . . . 4-15
ismissing, rmmissing, and groupsummary Functions: Accept data types with
no standard missing value . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-16
Functionality being removed or changed . . . . . . . . . . . . . . . . . . . . . . . . 4-16

Data Import and Export . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-18

Parquet: Read Parquet file data more efficiently using rowfilter to


conditionally filter rows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-18
Parquet: Determine and define row groups in Parquet file data . . . . . . . . 4-18
Parquet: Convert, import, and export nested data structures . . . . . . . . . 4-18
writelines Function: Write plain text to a file . . . . . . . . . . . . . . . . . . . . . . 4-18
Reading Online Data: Use web options when reading files over HTTP and
HTTPS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-18
Opus Files: Work with Opus (.opus) audio files. . . . . . . . . . . . . . . . . . . . . 4-19
HDF5 Interface: Write datasets using dynamically loaded filters . . . . . . . 4-19
NetCDF Interface: Enable byte-range reading of remote datasets . . . . . . 4-19
NetCDF Interface: Read and write variable length array data types
(NC_VLEN) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-19

xvii
Scientific File Format Libraries: NetCDF library is upgraded . . . . . . . . . 4-19
Hardware Manager App: Discover and connect to your hardware from
MATLAB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-19
TCP/IP Client Interface: Specify transfer delay options . . . . . . . . . . . . . . 4-19
Functionality being removed or changed . . . . . . . . . . . . . . . . . . . . . . . . 4-20

Mathematics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-21

pagemldivide, pagemrdivide, and pageinv Functions: Solve linear equations


and calculate matrix inverses using pages of N-D arrays . . . . . . . . . . . 4-21
tensorprod Function: Calculate tensor products between two arrays . . . . 4-21
round Function: Control tiebreak behavior . . . . . . . . . . . . . . . . . . . . . . . 4-21
null and orth Functions: Specify tolerance to treat singular values below a
threshold as zero . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-21
norm Function: Frobenius norm calculations support N-D arrays . . . . . . 4-21
equilibrate Function: Specify output format of factorization . . . . . . . . . . 4-21
rand, randi, and randn Functions: Support for complex input and
RandStream object with the "like" syntax . . . . . . . . . . . . . . . . . . . . . . 4-22
eps, flintmax, intmax, intmin, realmax, and realmin Functions: Use "like"
syntax to return scalars based on prototype object . . . . . . . . . . . . . . . 4-22
qr and gsvd Functions: Option for economy-size decompositions . . . . . . . 4-22
Functionality being removed or changed . . . . . . . . . . . . . . . . . . . . . . . . 4-22

Graphics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-23

Plotting Table Data: Create line plots by passing tables directly to plotting
functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-23
Data Tips: View table variable names as row labels . . . . . . . . . . . . . . . . . 4-23
Data Tips: View visual property values for scatter plots and bubble charts
..................................................... 4-24
Bubble Charts and 3-D Scatter Plots: Plot multiple data sets at once . . . . 4-25
fontname and fontsize Functions: Specify the font and font size for graphics
objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-26
exportgraphics Function: Create animated GIF files . . . . . . . . . . . . . . . . 4-26
Annotation Graphics Objects: Change the annotation rotation angle with the
Rotation property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-26
Quiver Plots: Align the heads, centers, or tails of arrows with data points
..................................................... 4-26
xlim, ylim, and zlim Functions: Query the axis limit method . . . . . . . . . . 4-27
view Function: Change the view on multiple axes simultaneously . . . . . . 4-27
rendererinfo Function: Get renderer information without specifying the axes
..................................................... 4-27
linkaxes Function: Synchronize axes in all dimensions by default . . . . . . 4-27
cameratoolbar Function: Syntax support for figures created with the
uifigure function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-28
Callbacks in Live Editor: Create callbacks for figures in the Live Editor . 4-28
Figure Code: Generate code for figure interactions in MATLAB Online . . 4-28
Functionality being removed or changed . . . . . . . . . . . . . . . . . . . . . . . . 4-29

App Building . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-32

uistyle Function: Add icons and format text in table cells and tree nodes
..................................................... 4-32
uitable Function: Rearrange columns of table UI components interactively
..................................................... 4-32

xviii Contents
focus Function: Give keyboard focus to UI components programmatically
..................................................... 4-33
isInScrollView Function: Determine if a component is visible in a scrollable
container . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-33
uigridlayout Function: Resize table, list box, and image UI components to fit
content . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-33
Live Editor Tasks: Develop your own Live Editor tasks for use in live scripts
and functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-34
Custom UI Components: Interactively create custom UI components in App
Designer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-34
App Designer: Modify tab focus order of components . . . . . . . . . . . . . . . 4-34
App Designer: Specify error handling options and navigate from error
messages when debugging an app . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-35
App Designer: Manage image files in your app with an improved workflow
..................................................... 4-35
App Designer: Convert components in a grid layout manager to use pixel-
based positioning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-35
App Designer: Use App Designer in most modern web browsers in MATLAB
Online . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-35
App Designer: Customize design environment layout . . . . . . . . . . . . . . . 4-35
Comparison Tool: Compare and merge app files in MATLAB Online . . . . . 4-36
Functionality being removed or changed . . . . . . . . . . . . . . . . . . . . . . . . 4-36

Performance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-38

table Data Type Indexing: Improved performance when subscripting with


dot notation or multiple levels of indexing . . . . . . . . . . . . . . . . . . . . . . 4-38
Classes: Improved performance for static methods, constant property
access, and package functions in scripts . . . . . . . . . . . . . . . . . . . . . . . 4-39
try Block: Improved performance when statements run error-free . . . . . 4-40
Python Data Type Conversion: Improved performance when converting
between Python and MATLAB data types in out-of-process mode . . . . . 4-41
MATLAB Engine API for Python: Improved performance with large
multidimensional arrays in Python . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-42
Matrix multiplication: Improved performance when multiplying sparse and
full matrices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-43
inv Function: Improved performance when inverting large triangular
matrices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-44
sprand and sprandn Functions: Improved performance when generating
random sparse matrices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-44
fzero Function: Improved performance . . . . . . . . . . . . . . . . . . . . . . . . . . 4-45
diff Function: Improved performance with large number of elements . . . 4-45
groupsummary, groupfilter, and grouptransform Functions: Improved
performance with small group size . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-46
nufftn Function: Improved performance with nonuniform sample points or
query points . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-46
Variables Editor and Live Editor: Improved speed of data display when
scrolling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-47
App Building: Improved performance when creating UI components . . . . 4-47
uitable Function and UI Containers: Improved performance when updating
properties successively . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-48
UI Components: Improved performance when setting a property with an
unchanged value . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-49
App Designer: Improved performance when loading apps with UIAxes
components off the canvas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-49

xix
Plots in Apps: Improved responsiveness for event-driven updates in apps
..................................................... 4-50
Plots in Apps: Improved responsiveness of axes interactions within apps
..................................................... 4-51
Plots in Apps: Improved responsiveness of axes interactions in plots with
two y-axes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-52
Plots in Apps: Faster animations in apps when multiple figures are open
..................................................... 4-53
Property Inspector: Improved performance when opening for the first time
..................................................... 4-54

Software Development Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-55

Projects: Reduce test runtime in continuous integration workflows using the


dependency cache . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-55
Dependency Analyzer: Save dependency graph as image . . . . . . . . . . . . 4-55
Code Compatibility Analyzer App: Identify and address compatibility issues
against current version of MATLAB . . . . . . . . . . . . . . . . . . . . . . . . . . 4-55
Unit Testing Framework: Create test classes interactively using the Current
Folder browser . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-55
Unit Testing Framework: Create temporary folders that are automatically
removed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-55
Unit Testing Framework: Generate DOCX, HTML, and PDF reports after
test execution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-56
Unit Testing Framework: Debug uncaught errors in tests . . . . . . . . . . . . 4-56
Unit Testing Framework: Collect statement and function coverage metrics
for your source code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-56
Functionality being removed or changed . . . . . . . . . . . . . . . . . . . . . . . . 4-56

External Language Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-58

C++ Interface: Array size help text for functions and methods . . . . . . . . 4-58
C Interface: Build third-party C library interface using
clibgen.generateLibraryDefinition . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-58
C++ Interface: Support for C++ language features . . . . . . . . . . . . . . . . 4-58
C++ Interface: Publisher options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-58
Call MATLAB from C++: Generate C++ code Interface for MATLAB
Packages, Classes, and Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-59
MATLAB Data Array API: matlab::data::Array support for row-major order
..................................................... 4-59
MEX Functions: UTF-8 system encoding on Windows platforms . . . . . . . 4-59
Python: Use Name=Value syntax to pass keyword arguments to Python
functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-59
Python: Convert Python list and tuple types to MATLAB types . . . . . . . . . 4-59
Perl 5.34.0: MATLAB support on Windows . . . . . . . . . . . . . . . . . . . . . . . 4-60
Compilers: Support for Microsoft Visual Studio 2022 . . . . . . . . . . . . . . . 4-60
Functionality being removed or changed . . . . . . . . . . . . . . . . . . . . . . . . 4-60

R2021b

Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-2

xx Contents
Editor Selection: Select and edit a rectangular area of code . . . . . . . . . . . 5-2
Editor Display: Zoom in and out in the Editor . . . . . . . . . . . . . . . . . . . . . . 5-2
Editor Code: Show code suggestions and completions automatically . . . . . 5-2
Editor Debugging: Diagnose problems in scripts and functions using inline
debugging controls and a breadcrumb-style function call stack . . . . . . . 5-3
Editor Refactoring: Automatically convert selected code to a function . . . . 5-4
Editor Code: Automatically complete block endings, match delimiters, and
wrap comments while editing code . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-4
Editor Sections: Create sections with an improved appearance . . . . . . . . . 5-4
Editor Code: Change the case of text and code . . . . . . . . . . . . . . . . . . . . . 5-5
Editor Bookmarks: Maintain bookmarks after closing a file . . . . . . . . . . . . 5-5
Live Editor Controls: Set default values for sliders, drop-down lists, check
boxes, and edit fields . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-5
Live Editor Animations: Export animations to movies or animated GIFs . . 5-6
Live Editor Figures: Interact with real MATLAB figures and resize them
with improved layouts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-6
Live Editor: Improved performance when saving live scripts or functions
...................................................... 5-7
Comparison Tool: Compare and merge text files with improved usability,
appearance, and syntax highlighting . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-7
Importing Preferences from Previous Releases: MATLAB checks for
preferences from R2019b or newer . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-8
Display language: MATLAB uses Windows display language settings for
selecting desktop language . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-8
Functionality being removed or changed . . . . . . . . . . . . . . . . . . . . . . . . . 5-8

Language and Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-10

cast Function: Consistent output for all syntaxes with the same data type
conversion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-10
Run Code in the Background: Use parallel language to run code
asynchronously . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-10
Portable Parallel Code: Share parallel code and seamlessly run in parallel
..................................................... 5-10
Compact Display for Classes: Customize display of information about
classes when space is limited . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-11
Class Aliasing: Create aliases for renamed classes to maintain backward
compatibility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-11
Modular Indexing: Customize class indexing operations individually using
new superclasses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-11
Scalar Classes: Inherit from the matlab.mixin.Scalar superclass to ensure
instances behave as scalars . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-12
startat Function: Time zone information in datetime objects now supported
..................................................... 5-12
Functionality being removed or changed . . . . . . . . . . . . . . . . . . . . . . . . 5-12

Data Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-14

Compute by Group Live Editor Task: Interactively summarize, transform, or


filter groups of data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-14
Normalize Data Live Editor Task: Interactively center and scale data . . . 5-14
Clean Missing Data Live Editor Task: Define missing values . . . . . . . . . . 5-14
trenddecomp Function: Find trends in data . . . . . . . . . . . . . . . . . . . . . . 5-14
min and max Functions: Specify the comparison method for determining
minimum and maximum values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-14

xxi
uniquetol Function: Options to control element selection and preserve range
of data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-14
Data Preprocessing Functions: Specify table variable as sample points
vector . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-14
dateshift Function: Shift to next occurrence of weekday or weekend day
..................................................... 5-15
isbetween Function: Support for open, closed, and half open intervals . . 5-15
isregular Function: Support for datetime and duration data types . . . . . . 5-15
istabular Function: Determine if input is a table or timetable . . . . . . . . . 5-15
retime and synchronize Functions: Median and mode methods supported
..................................................... 5-15
timeofday Function: Return the date as the second output argument . . . 5-15
timeseries2timetable Function: Convert timeseries objects to timetables
..................................................... 5-16
Functionality being removed or changed . . . . . . . . . . . . . . . . . . . . . . . . 5-16

Data Import and Export . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-17

sftp Function: Connect to SFTP servers . . . . . . . . . . . . . . . . . . . . . . . . . 5-17


Datastores: Specify FileSet objects as data locations for some datastores
..................................................... 5-17
Table Import: Read tables from HTML and Microsoft Word documents . . 5-17
HDF5 Interface: Use new functionality in support of HDF5 1.10.7 . . . . . 5-17
NetCDF Interface: Read and write NC_STRING data . . . . . . . . . . . . . . . 5-18
Scientific File Format Libraries: HDF5 and NetCDF libraries are upgraded
..................................................... 5-18
Audio, Video, and Image I/O Functions: Run functions in a thread-based
environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-18
Image File Format Libraries: LibTIFF library upgraded to version 4.2.0 . 5-18
New Serial Explorer and TCP/IP Explorer apps . . . . . . . . . . . . . . . . . . . . 5-18
Functionality being removed or changed . . . . . . . . . . . . . . . . . . . . . . . . 5-19

Mathematics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-20

ode78 and ode89 Functions: High-order Runge-Kutta solvers for ordinary


differential equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-20
pagesvd Function: Perform singular value decomposition on pages of N-D
arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-20
svd Function: Option to control output format of singular values . . . . . . . 5-20
mpower Function: Improved algorithm for defective matrices . . . . . . . . . 5-20
Functionality being removed or changed . . . . . . . . . . . . . . . . . . . . . . . . 5-20

Graphics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-21

Plotting Table Data: Create scatter plots, bubble charts, and swarm charts
by passing tables directly to plotting functions . . . . . . . . . . . . . . . . . . 5-21
Axes Ticks and Colors: Control the appearance of axis tick marks and tick
label colors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-22
Create Plot Live Task: Add additional visualizations to generated plots . . 5-23
Create Plot Live Task: Control chart input syntax using configuration drop-
down . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-24
exportgraphics Function: Capture and append graphics to existing PDFs
..................................................... 5-24
stackedplot Function: Support for semilog y-axes . . . . . . . . . . . . . . . . . . 5-24
Text Objects: Use editInteractions in the Interactions property to click or
tap on text to edit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-24

xxii Contents
dataTipTextRow Function: Customize data tip content using data properties,
such as UserData . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-24
MATLAB Online™ Accessibility: Use a screen reader to interact with figures
..................................................... 5-25
Functionality being removed or changed . . . . . . . . . . . . . . . . . . . . . . . . 5-25

App Building . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-26

uialert, uiconfirm, and uiprogressdlg Functions: Mark up text and display


equations in dialog boxes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-26
addStyle Function: Add styles to nodes and levels in a tree UI component
..................................................... 5-26
uitable Function: Set and query table selections programmatically and
control table selection options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-26
uitextarea Function: Program apps to respond while a user is typing in a
text area component . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-26
Run Code in the Background: Use parallel language to create more
responsive apps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-26
App Designer: Debug code in Code View . . . . . . . . . . . . . . . . . . . . . . . . . 5-27
App Designer: Efficiently manage your app code with tools and shortcuts
from Live Editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-27
App Designer: Interactively modify canvas zoom level and fit canvas to view
..................................................... 5-29
App Designer: Convert between similar UI components . . . . . . . . . . . . . 5-29
App Designer: Add help text for your app . . . . . . . . . . . . . . . . . . . . . . . . 5-30
App Designer: Remove auto-reflow behavior from an app with auto-reflow
..................................................... 5-30
Deployed Web Apps: Deploy web apps directly to the MATLAB Web App
Server from within App Designer . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-30
App Testing Framework: Perform press gestures on axes and UI axes with
different selection types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-30
App Testing Framework: Perform drag gestures on axes and figures with
different selection types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-31
App Testing Framework: Use any units of measurement in gestures at the
center of components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-31
Functionality being removed or changed . . . . . . . . . . . . . . . . . . . . . . . . 5-31

Performance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-33

table Data Type Indexing: Improved performance when assigning elements


by subscripting with curly braces . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-33
qrinsert and qrdelete Functions: Improved performance modifying QR
factorizations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-33
Titles and Labels in Plots: Improved performance when creating and
querying titles or labels in a loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-34
Plot Interactions: Improved performance for rendering data tips and
rotating scatter plots of large data sets . . . . . . . . . . . . . . . . . . . . . . . . 5-35
Plots in Apps: Improved performance for creating plots . . . . . . . . . . . . . 5-35
App Designer: Improved performance when opening Start Page and loading
apps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-36
App Designer: Improved performance when saving apps . . . . . . . . . . . . . 5-36
Comparison Tool: Improved performance when loading and saving MLAPP
files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-37
uigridlayout Function: Improved performance when adding components
spanning multiple columns with 'fit' width . . . . . . . . . . . . . . . . . . . . . 5-37

xxiii
uigridlayout Function: Improved resizing performance when wrapping text
in resizable columns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-38
Live Editor: Improved performance when saving live scripts or functions
..................................................... 5-39
Data Processing Dialog Boxes: Improved resizing performance . . . . . . . . 5-39
Figure Interactions: Improved performance when using built-in axes
interactions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-39
UI Figures: Improved performance when displaying axes toolbar . . . . . . 5-40
UI Figures: Improved performance when interacting with linked axes . . 5-40

Software Development Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-41

Projects: Collaborate using projects in MATLAB Online . . . . . . . . . . . . . . 5-41


Source Control: Work with files under Git in MATLAB Online . . . . . . . . . 5-41
Unit Testing Framework: Use the TestCase class template to create tests
more quickly and accurately . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-41
Unit Testing Framework: Run live-function-based tests interactively in
MATLAB Online . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-41
App Testing Framework: Perform press gestures on axes and UI axes with
different selection types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-41
App Testing Framework: Perform drag gestures on axes and figures with
different selection types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-42
App Testing Framework: Use any units of measurement in gestures at the
center of components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-42
Functionality being removed or changed . . . . . . . . . . . . . . . . . . . . . . . . 5-42

External Language Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-44

C++ interface: Support for C++ language features . . . . . . . . . . . . . . . . 5-44


C++ interface: Publisher options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-44
Java interface: Specify JRE path for MATLAB . . . . . . . . . . . . . . . . . . . . . 5-45
Java: Call into MATLAB from a Java program called by MATLAB . . . . . . . 5-45
Python interface: Run Python commands and scripts from MATLAB . . . . 5-45
Python: Support for complex multidimensional arrays . . . . . . . . . . . . . . . 5-45
Python: Version 3.9 support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-46
WSDL Web Services Documents: Apache CXF version 3.4.2 support . . . . 5-46
Perl 5.32.1: MATLAB support on Windows . . . . . . . . . . . . . . . . . . . . . . . 5-46
Functionality being removed or changed . . . . . . . . . . . . . . . . . . . . . . . . 5-47

Hardware Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-49

Connect and Control Arduino board using the Arduino Explorer App . . . 5-49
Read data from APDS9960 sensor connected to the Arduino hardware . . 5-49
Support for CAN shields on Raspberry Pi Hardware . . . . . . . . . . . . . . . . 5-49

R2021a

Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-2

Live Editor Controls: Create dynamic controls in live scripts by linking


variables to drop-down items and slider values . . . . . . . . . . . . . . . . . . . 6-2

xxiv Contents
Live Editor Fonts: Change the name, style, size, and color of fonts
programmatically using settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-3
Live Editor Display: Specify where to display output by default . . . . . . . . . 6-3
Live Editor Functions: Run live functions interactively using the Run button
in MATLAB Online . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-4
Live Editor Bookmarks: Navigate quickly between lines . . . . . . . . . . . . . . 6-4
Live Editor Animation Playback Controls: Interactive interface to control
animations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-4
Live Editor Performance: Improved performance when saving large live
scripts or functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-4
Help Browser: View web documentation by default . . . . . . . . . . . . . . . . . . 6-5
Documentation: View MATLAB documentation in French, Italian, and
German . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-5
MATLAB Drive: Get the location of your MATLAB Drive root folder
programmatically . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-5
MATLAB Drive: Pause and resume syncing in MATLAB Drive Connector
...................................................... 6-5
MATLAB Drive: MATLAB Drive Connector now available in Chinese and
Korean . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-5
MATLAB Drive: Change the folder permissions for an invited member of a
shared folder in MATLAB Drive Online (May 2021) . . . . . . . . . . . . . . . . 6-5
MATLAB Drive: Share folder by invitation to others who already have access
to the folder through a view-only link (May 2021) . . . . . . . . . . . . . . . . . 6-6
Functionality being removed or changed . . . . . . . . . . . . . . . . . . . . . . . . . 6-6

Language and Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-7

Name=Value Syntax: Use name=value syntax for passing name-value


arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-7
Retrieving Display Format: format function can get and set display format
...................................................... 6-7
Capturing disp Output: Use the formattedDisplayText function to store disp
output as a string . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-8
Virtual File Storage: mkdir and rmdir will now be able to create and remove
files from VFS directories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-8
Function Argument Validation: Debugger and profiler is now supported
...................................................... 6-8
Class Diagram Viewer: Create graphical class diagrams to explore class
details and share designs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-8
Enumeration Comparisons: Use isequal to compare enumeration members
with text data types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-8
eval function: Context checking to resolve identifiers . . . . . . . . . . . . . . . . 6-9
Functionality being removed or changed . . . . . . . . . . . . . . . . . . . . . . . . 6-10

Data Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-12

Data Preprocessing Live Editor Tasks: Operate on multiple table variables


and specify output format for table input . . . . . . . . . . . . . . . . . . . . . . 6-12
Clean Outlier Data Live Editor Task: Visualize results with a histogram . 6-12
fillmissing Function: Specify custom fill method . . . . . . . . . . . . . . . . . . . 6-12
normalize Function: Normalize multiple data sets with same parameters
..................................................... 6-12
groupcounts Function: Display percentages of group counts . . . . . . . . . . 6-13
ts2timetable Function: Convert timeseries objects to timetables . . . . . . . 6-13
table and timetable Functions: Specify dimension names using the
'DimensionNames' name-value argument . . . . . . . . . . . . . . . . . . . . . . 6-13

xxv
Functionality being removed or changed . . . . . . . . . . . . . . . . . . . . . . . . 6-13

Data Import and Export . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-15

XML Files: Read, write, and import XML files using readtable,
readtimetable, and other functions . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-15
MATLAB API for Advanced XML Processing: Create, read, write, transform,
and query XML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-15
XML Files: Register XML namespace prefixes for evaluating XPath
expressions using readtable,readstruct, and other functions . . . . . . . . 6-15
Low-level file I/O functions and remote data: Perform read and write
operations on remotely stored files . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-16
save and load functions and remote data: Save, load, and append data to
remotely stored v7.3 MAT-files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-16
Reading Online Data: Read files over HTTP and HTTPS using readtable,
audioread, and other reading functions . . . . . . . . . . . . . . . . . . . . . . . . 6-16
Parquet Data Format: Use categorical data in parquet data format . . . . . 6-17
Datastores: Read all data from a datastore using parallel processing . . . 6-17
Data Compression Functions: Improved functionality in zip/unzip and tar/
untar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-17
imfinfo function: Get information about all Adobe Digital Negative (DNG)
file tags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-17
jsonencode: Add indentation to JSON text . . . . . . . . . . . . . . . . . . . . . . . . 6-17
Functionality being removed or changed . . . . . . . . . . . . . . . . . . . . . . . . 6-18

Mathematics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-20

Graph Algorithms: Compute all paths, all cycles, and cycle basis . . . . . . 6-20
griddedInterpolant Object: Use multivalued interpolation to interpolate
multiple data sets simultaneously . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-20
eig Function: Improved algorithm for skew-Hermitian matrices . . . . . . . 6-20
cdf2rdf Function: Improved algorithm for all inputs . . . . . . . . . . . . . . . . 6-20
Functionality being removed or changed . . . . . . . . . . . . . . . . . . . . . . . . 6-20

Graphics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-22

Create Plot Live Editor Task: Create plots interactively and generate code
..................................................... 6-22
bubblecloud Function: Visualize part-to-whole relationships . . . . . . . . . . 6-22
tiledlayout Function: Control the tile indexing scheme . . . . . . . . . . . . . . 6-22
PolarAxes Objects: Use the CurrentPoint property or call ginput to get the
cursor location within polar axes . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-23
Scatter Plots and Constant Lines: Create multiple scatter plots or constant
lines at once . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-23
Axis Limits: Define LimitsChangedFcn callback that executes when the
limits of an axis change . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-23
Axis Limits: Control axis limits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-23
exportgraphics and copygraphics Functions: Specify RGB, CMYK, or
grayscale output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-24
colororder Function: Control colors in stacked plots . . . . . . . . . . . . . . . . 6-24
Tick Labels: Automatically rotate tick labels . . . . . . . . . . . . . . . . . . . . . . 6-24
patch and errorbar Functions: Expanded data type support . . . . . . . . . . 6-25
Geographic Plots: Access basemaps using additional proxy server
authentication types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-25
Functionality being removed or changed . . . . . . . . . . . . . . . . . . . . . . . . 6-25

xxvi Contents
App Building . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-32

uihyperlink Function: Add and configure clickable links in apps and on the
App Designer canvas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-32
uitree Function: Add and configure check box trees in apps and on the App
Designer canvas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-32
Interpreter Property: Style text and display equations in labels with HTML
and LaTeX markup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-32
WindowStyle Property: Create UI figures that remain in the foreground
..................................................... 6-32
scroll Function: Scroll to a location within a table UI component
programmatically . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-32
UI Component Accessibility: Select ListBox items, Table cells, ColorPicker
colors, and DatePicker menus using the keyboard . . . . . . . . . . . . . . . . 6-33
App Designer: Use custom UI components in App Designer . . . . . . . . . . 6-33
App Designer: Zoom and pan in the canvas, and zoom in the Code View
editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-34
App Designer: Control color and tab settings in Code View using MATLAB
preferences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-34
App Designer: Customize split-screen layouts in the App Designer editor
..................................................... 6-34
App Testing Framework: Perform gestures on panels and tables . . . . . . . 6-34
App Testing Framework: Close alert dialog box in front of figure window
..................................................... 6-35
Web Apps and Standalone Applications: Datatips supported in graphics . 6-35
Functionality Being Removed or Changed . . . . . . . . . . . . . . . . . . . . . . . . 6-35

Performance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-37

Sparse Matrix Multiplication: Improved performance multiplying large


sparse matrices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-37
Sparse Linear Systems: Improved performance solving sparse linear
systems A*X = B with multicolumn B . . . . . . . . . . . . . . . . . . . . . . . . . 6-37
vecnorm Function: Improved performance operating on data with multiple
columns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-38
ismember Function: Improved performance for cell inputs . . . . . . . . . . . 6-38
unique Function: Improved performance for numeric, logical, char, and cell
inputs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-39
Graph Functions: Improved performance modifying node and edge lists
..................................................... 6-40
Axes Toolbar: Appears without delay when axes are ready . . . . . . . . . . . 6-40
Rearranging UI Components: Improved performance when rearranging UI
components in a UI figure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-40
UI Figure Interactions: Faster responses to scroll, pointer movement, and
resize interactions in UI figures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-41
Plots in Apps: Improved performance for polar plots, volume visualizations,
plots with more than 16 axes, and older systems . . . . . . . . . . . . . . . . . 6-42
Plots in Apps: Improved performance for plots with large numbers of
markers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-43
Live Editor: Improved performance when saving large live scripts or
functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-43

Software Development Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-45

Projects: List all referenced projects of the current project . . . . . . . . . . . 6-45


Projects: List impacted project files . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-45

xxvii
Dependency Analyzer: Find required add-ons . . . . . . . . . . . . . . . . . . . . . 6-45
Unit Testing Framework: Create test runners using alternative syntax . . 6-45
Unit Testing Framework: Initialize parameterization properties at suite
creation time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-45
Unit Testing Framework: Run tests in parallel on thread-based pool . . . . 6-45
Unit Testing Framework: Run tests in MATLAB Online interactively . . . . 6-46
App Testing Framework: Perform gestures on panels and tables . . . . . . . 6-46
App Testing Framework: Close alert dialog box in front of figure window
..................................................... 6-46
Functionality being removed or changed . . . . . . . . . . . . . . . . . . . . . . . . 6-46

External Language Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-47

C++ Interface: Support for C++ language features . . . . . . . . . . . . . . . . 6-47


C++ Interface: Publisher options and analysis . . . . . . . . . . . . . . . . . . . . 6-47
Java Packages to be removed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-47
Java Engine: MATLAB value object support . . . . . . . . . . . . . . . . . . . . . . . 6-47
Python Interface and Engine: Version 3.6 support discontinued . . . . . . . 6-47
Perl 5.32.0: MATLAB support on Windows . . . . . . . . . . . . . . . . . . . . . . . 6-48

Hardware Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-49

Support added for IMU sensors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-49


New functionalities added to Raspberry Pi Resource Monitor app . . . . . . 6-49

R2020b

Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-2

MATLAB Online Accessibility: Use a screen reader to interact with the


Command Window and create scripts and functions . . . . . . . . . . . . . . . 7-2
Live Editor Images: Add alternative text to images . . . . . . . . . . . . . . . . . . 7-2
Live Editor Images: Change the size of images . . . . . . . . . . . . . . . . . . . . . 7-2
Live Editor Hyperlinks: Navigate to existing files from a live script or live
function using links . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-2
Live Editor Export: Export all live scripts and live functions in a folder to a
standard format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-2
matlabRelease Object: Query MATLAB Release Information . . . . . . . . . . . 7-3
Query Parallel Functionality: Determine if support for Parallel Computing
Toolbox functionality is available . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-3
Comparison Tool: Compare text files in MATLAB Online . . . . . . . . . . . . . . 7-3
MATLAB Drive: Decreased password confirmation requests in MATLAB
Drive Connector . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-3
MATLAB Drive: Faster shut down of MATLAB Drive Connector when
syncing is in progress . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-4
MATLAB Drive: Integration with OS-specific password management systems
...................................................... 7-4
MATLAB Drive: MATLAB Drive Connector available in Japanese . . . . . . . . 7-4
MATLAB Drive: Download folders from MATLAB Drive online to your
desktop (December 2020) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-4
MATLAB Drive: Preview the contents of a shared folder in MATLAB Drive
online before accepting invitation (December 2020) . . . . . . . . . . . . . . . 7-4

xxviii Contents
Language and Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-5

pattern Object and Functions: Match patterns in text functions . . . . . . . . 7-5


extract Function: Extract substrings from strings . . . . . . . . . . . . . . . . . . . 7-5
Functions: New validation functions for arguments and properties . . . . . . 7-5
underlyingType, isUnderlyingType, and mustBeUnderlyingType Functions:
Query the underlying data type of classes . . . . . . . . . . . . . . . . . . . . . . . 7-6
height and width Functions: Return number of rows or columns in an array
...................................................... 7-6
Class conversions: Assignment operations convert more classes into built-in
data types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-6
Functionality being removed or changed . . . . . . . . . . . . . . . . . . . . . . . . . 7-7

Data Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-8

Implicit Expansion: For calendarDuration, categorical, datetime, and


duration arrays, automatically expand dimensions of length 1 when
applying element-wise operations and functions . . . . . . . . . . . . . . . . . . 7-8
normalize Function: Scale data by interquartile range . . . . . . . . . . . . . . . 7-9
groupsummary Function: Summarize data using functions that require
multiple input arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-9
fillmissing Function and Clean Missing Data Live Editor Task: Specify
maximum gap size to fill . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-9
Clean Outlier Data Live Editor Task: Define outliers based on percentile
thresholds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-9
Functionality being removed or changed . . . . . . . . . . . . . . . . . . . . . . . . . 7-9

Data Import and Export . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-11

readstruct and writestruct functions: Read and write structured data in


XML files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-11
readlines function: Read the lines in a text file as a string array . . . . . . . 7-11
Spreadsheet files: Customize formatting when writing data to spreadsheet
files with PreserveFormat and AutoFitWidth . . . . . . . . . . . . . . . . . . . . 7-11
imread function and Tiff object: Read images from Aperio SVS and TIFF
files containing JPEG2000 compression . . . . . . . . . . . . . . . . . . . . . . . 7-11
ArrayDatastore object: Create datastores from in-memory data . . . . . . . 7-11
Datastore: Transform multiple datastores using the transform function . 7-11
FileDatastore object: Shuffle and create subsets of a FileDatastore . . . . . 7-12
writeall function: Write data from text and spreadsheet files to different row
groups in Parquet files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-12
fileparts function: Parse file names specified as cell arrays of character
vectors and string arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-12
Audio devices: Refresh the available audio devices using the audiodevreset
function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-12
Audio files and web-based data: Read and write remotely stored audio files
using audioread, audiowrite, and audioinfo . . . . . . . . . . . . . . . . . . . . . 7-12
HDF5 files and web-based data: Read and write remotely-stored HDF5 files
using existing HDF5 functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-13
HDF5 files: Read and write file names encoded using Unicode characters
..................................................... 7-13
Scientific File Format Libraries: NetCDF library upgraded to 4.7.3 . . . . . 7-13
Image File Format Libraries: LibTIFF library upgraded to version 4.1.0 . 7-13
Bluetooth Interface: Support for communicating with Bluetooth devices
..................................................... 7-13
TCP/IP Client Interface: New functions and properties . . . . . . . . . . . . . . 7-14

xxix
Serial Port Interface: Improved performance . . . . . . . . . . . . . . . . . . . . . 7-14
Functionality being removed or changed . . . . . . . . . . . . . . . . . . . . . . . . 7-15

Mathematics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-17

Optimize Live Editor Task: Solve optimization problems interactively . . . 7-17


pagemtimes Function: Perform matrix multiplication on pages of N-D arrays
..................................................... 7-17
pagetranspose and pagectranspose Functions: Transpose pages of N-D
arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-17
svdsketch Function: Compute SVD factors of low-rank matrix sketch . . . 7-17
Functionality being removed or changed . . . . . . . . . . . . . . . . . . . . . . . . 7-17

Graphics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-18

bubblechart, bubblechart3, and polarbubblechart Functions: Create bubble


charts in 2-D, 3-D, and in polar coordinates . . . . . . . . . . . . . . . . . . . . . 7-18
Swarm charts and Scatter objects: Visualize distributions of discrete data
..................................................... 7-18
scatter Function: Vary the transparency across all points . . . . . . . . . . . . 7-19
tiledlayout and nexttile Functions: Improved placement of legends, and
colorbars, and shared decorations . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-19
axis Function: Pad axis limits to show plotted data near the limits more
clearly . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-20
Titles, Subtitles, and Axis Labels: Add subtitles to plots, and align titles and
axis labels with the plot box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-21
Data Tips: Customize data tip content on standalone visualizations . . . . . 7-22
turbo Colormap: jet colormap alternative with more perceptually uniform
transitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-23
Colormap Editor: Customize colormaps using modernized interface . . . . 7-23
boxchart Function: Use color to differentiate between box charts . . . . . . 7-24
im2gray and cmap2gray: Convert images and colormaps to grayscale . . . 7-24
validatecolor Function: Calculate normalized RGB triplets for color names,
hexadecimal color codes, or integer values . . . . . . . . . . . . . . . . . . . . . 7-24
Markers: Specify horizontal or vertical line markers for plots . . . . . . . . . 7-25
surfc and meshc Functions: Specify Z-level for contours on surface and
mesh plots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-25
animatedline Function: Create animated lines in polar plots . . . . . . . . . . 7-26
colororder Function: Control colors in geographic bubble charts . . . . . . 7-26
Functionality being removed or changed . . . . . . . . . . . . . . . . . . . . . . . . 7-26

App Building . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-30

uitable Function: Configure column widths to use weighted variable or to


automatically adjust to fit data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-30
scroll Function: Scroll to the top or bottom of a text area programmatically
..................................................... 7-30
WindowStyle Property: Create modal UI figures . . . . . . . . . . . . . . . . . . . 7-30
Icon Property: Specify custom icons for UI figure windows and toolbar push
and toggle tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-30
WordWrap Property: Wrap long text to fit the width of certain UI
components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-30
Enable Property: Turn interaction off and on for buttons and panel groups
..................................................... 7-31
BackgroundColor Property: Set the background color for grid layouts . . 7-31
Custom Components: Develop your own class of UI components . . . . . . . 7-31

xxx Contents
App Designer: Allow only one running instance of your app at a time . . . 7-31
App Designer: Change the stacking order of UI components . . . . . . . . . . 7-32
App Designer: Add and configure toolbar components on the App Designer
canvas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-32
App Designer: Draw UI components on the App Designer canvas . . . . . . 7-32
App Designer: Find differences and merge apps . . . . . . . . . . . . . . . . . . . 7-32
Graphics Support: Create more plots in apps with full support for any type
of axes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-33
Graphics Support: Identify coordinates and display text by clicking or
tapping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-33
App Capture: Capture user interfaces using exportapp and getframe . . . 7-33
App Testing Framework: Perform choose gestures on context menu items
..................................................... 7-34
App Testing Framework: Perform drag gestures on axes and UI axes . . . 7-34
App Testing Framework: Perform gestures on push tools and toggle tools
..................................................... 7-34
Functionality Being Removed or Changed . . . . . . . . . . . . . . . . . . . . . . . . 7-34

Performance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-38

sum Function: Improved performance summing the first dimension of


numeric arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-38
polyfit Function: Improved performance fitting data . . . . . . . . . . . . . . . . 7-38
accumarray Function: Improved performance with fill values and certain
function handles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-39
spdiags Function: Improved performance constructing sparse banded
matrices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-40
uilistbox: Improved performance when setting multiple items in a list box
..................................................... 7-41
uitree: Improved performance when creating many nodes in a tree . . . . . 7-41
Data Tip Markers: Improved rendering performance of data tip markers in
surface plots of large data sets created in UI figures and MATLAB Online
..................................................... 7-42

Software Development Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-43

Code Compatibility Report: Unsupported Functionality Will Now Issue


Warning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-43
Dependency Analyzer: Export to archive and generate a dependency report
..................................................... 7-43
Source Control: Improved workflow to set up Git source control . . . . . . . 7-43
Projects: Change project definition file type and preserve source control
history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-43
Unit Testing Framework: Run tests in parallel on clusters and clouds . . . 7-43
Unit Testing Framework: Run tests in parallel with standalone applications
..................................................... 7-44
Unit Testing Framework: Report the validity of shared test fixtures . . . . 7-44
App Testing Framework: Perform choose gestures on context menu items
..................................................... 7-44
App Testing Framework: Perform drag gestures on axes and UI axes . . . 7-44
App Testing Framework: Perform gestures on push tools and toggle tools
..................................................... 7-44
Functionality being removed or changed . . . . . . . . . . . . . . . . . . . . . . . . 7-45

External Language Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-47

xxxi
C++ Interface: Support for nullptr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-47
C++ Interface: Create interface with C++ source files . . . . . . . . . . . . . . 7-47
Python: Version 3.8 support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-47
Python: Terminate Python interpreter and start new one in same MATLAB
session . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-47
mxCreateString C Matrix API functions: UTF-8 support . . . . . . . . . . . . . 7-47
MATLAB Data API: Create matlab::data::Object arrays . . . . . . . . . . . . . . 7-47
Compiler support changed for building C++ interfaces, MEX files, and
standalone MATLAB engine and MAT-file applications . . . . . . . . . . . . . 7-48
Functionality being removed or changed . . . . . . . . . . . . . . . . . . . . . . . . 7-48

Hardware Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-49

Live Editor Task: Interactively capture images from USB Webcam


interactively and generate MATLAB code in a live script. . . . . . . . . . . 7-49
Functionality being removed or changed . . . . . . . . . . . . . . . . . . . . . . . . 7-49

R2020a

Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-2

Profiler Flame Graphs: Investigate and improve the performance of your


code visually . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-2
Live Editor Loop Execution: Improved performance when running loops in
live scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-2
Live Editor Animation Output: Improved performance when animating plots
in live scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-3
Live Editor Responsiveness: Improved performance with extended use . . . 8-3
Live Editor Control Value Changes: Run all necessary code on value
changes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-3
File Encoding: Save MATLAB code files (.m) and other plain text files as
UTF-8 encoded files by default . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-3
Multiple Sources in Help Browser: Search MathWorks documentation and
custom documentation together in a single browser . . . . . . . . . . . . . . . 8-4
Web Documentation: View MathWorks documentation on the web without
logging in . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-4
Internationalization: UTF-8 as system encoding on Mac and Windows
platforms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-5

Language and Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-6

switch Function: Compare objects more flexibly . . . . . . . . . . . . . . . . . . . . 8-6


copyfile and movefile Functions: Access web-based storage services like
Amazon Web Services and Azure Blob Storage . . . . . . . . . . . . . . . . . . . 8-6
dbup and dbdown Commands: Switch between workspaces with one step
...................................................... 8-6
bin2dec and hex2dec Functions: Convert text that includes binary or
hexadecimal prefixes and suffixes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-6
dec2bin and dec2hex Functions: Convert negative numbers . . . . . . . . . . . 8-7
complex Function: Create sparse complex arrays . . . . . . . . . . . . . . . . . . . 8-7
Enumeration classes: Hide member names for compatible name changes
...................................................... 8-7

xxxii Contents
matlab.mixin.SetGet: Set priority for partial property name matching . . . . 8-7
Class logical conversions: Support logical conversion more flexibly when
writing classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-7
Functionality being removed or changed . . . . . . . . . . . . . . . . . . . . . . . . . 8-8

Data Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-12

Live Editor Tasks: Interactively manipulate tables and timetables, and


generate code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-12
Basic Fitting Tool: Fit lines to plotted data using modernized interface . . 8-12
detrend Function: Ignore NaN values . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-13
accumarray Function: Maintain consistent output order on all platforms
..................................................... 8-13
leapseconds Function: List all leap seconds used by the datetime data type
..................................................... 8-13
timezones Function: Determine IANA Time Zone Database version . . . . . 8-14
renamevars Function: Rename variables in table or timetable . . . . . . . . . 8-14
rows2vars and unstack Function: Use naming rule to allow table and
timetable variable names with any characters . . . . . . . . . . . . . . . . . . . 8-14
containsrange, overlapsrange, and withinrange Functions: Determine if
timetable row times intersect specified time range . . . . . . . . . . . . . . . 8-14
tall Arrays: Operate on tall arrays with more functions, including groupfilter
and matches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-15
Functionality Being Removed or Changed . . . . . . . . . . . . . . . . . . . . . . . . 8-16

Data Import and Export . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-17

Datastores: Write data from datastore to files using writeall . . . . . . . . . . 8-17


Datastores: Return timetables from tabularTextDatastore and
spreadsheetDatastore objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-17
Datastores: Partition and shuffle TransformedDatastore and
CombinedDatastore objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-17
Datastores: Process files and blocks within files iteratively using FileSet and
BlockedFileSet objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-17
Parquet Files: Control encoding scheme and Parquet version when writing
files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-17
Text and Spreadsheet Files: Append, overwrite, or replace data using
'WriteMode' parameter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-18
readtable Function: Uses results of detectImportOptions function by default
..................................................... 8-18
textscan, readtable, detectImportOptions, and setvaropts Functions: Read
and import hexadecimal and binary literals . . . . . . . . . . . . . . . . . . . . . 8-19
h5read and h5readatt: Read non-scalar string data as MATLAB string arrays
..................................................... 8-19
h5create and h5write: Write string data to HDF5 files . . . . . . . . . . . . . . 8-19
CDF Library: Upgraded to v3.7.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-20
Tiff Object: Read and write the values of the Rational Polynomial
Coefficients tag . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-20
jsonencode: Customize encoding in MATLAB classes . . . . . . . . . . . . . . . 8-20
jsonencode: Encode enumerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-20
Functionality being removed or changed . . . . . . . . . . . . . . . . . . . . . . . . 8-20

Mathematics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-22

nufft and nufftn Functions: Compute nonuniform fast Fourier transforms


..................................................... 8-22

xxxiii
sparse Function: Support for integer subscripts and logical aggregation
..................................................... 8-22

Graphics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-23

boxchart Function: Visualize grouped numeric data by using box charts


..................................................... 8-23
exportgraphics and copygraphics Functions: Save and copy graphics with
improved support for publishing workflows . . . . . . . . . . . . . . . . . . . . . 8-23
ChartContainer Class: Develop charts that display a tiling of Cartesian,
polar, or geographic plots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-24
Tiled Chart Layout: Position, nest, and change the grid size of layouts . . 8-24
pie Function: Specify a numeric format for the percentage labels . . . . . . 8-24
Axes Convenience Functions: Pass an array of axes or chart objects to
convenience functions such as grid, hold, and box . . . . . . . . . . . . . . . 8-25
SeriesIndex and NextSeriesIndex Properties: Control how plots cycle
through colors and line styles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-25
colororder Function: Control colors in scatter histograms and parallel plots
..................................................... 8-25
pareto Function: Specify the fraction of the cumulative histogram to include
..................................................... 8-25
Axes: Control margins for titles and labels by setting the InnerPosition and
PositionContraint properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-26
Built-In Axes Interactions: Explore data with cursors that show available
interactions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-26
Built-In Axes Interactions: Customize built-in interactions on geographic
axes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-27
linkdata Function: Open dialog box to specify data sources using new syntax
..................................................... 8-27
Functionality being removed or changed . . . . . . . . . . . . . . . . . . . . . . . . 8-27

App Building . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-30

uicontextmenu Function: Add and configure context menu components in


apps and on the App Designer canvas . . . . . . . . . . . . . . . . . . . . . . . . . 8-30
uitoolbar Function: Add custom toolbars to apps programmatically . . . . . 8-30
Icon Property: Display SVG, animated GIF, or truecolor image array icons in
buttons and tree nodes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-30
Mouse Pointer: Change the mouse pointer symbol in apps . . . . . . . . . . . 8-30
Graphics Support: Create annotations, brush data, configure data tips, save
and copy graphics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-30
GUIDE to App Designer Migration Tool for MATLAB: Migrate GUIDE apps
to App Designer in less time and with fewer manual code updates . . . 8-31
App Testing Framework: Perform press gestures with different selection
types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-31
Functionality Being Removed or Changed . . . . . . . . . . . . . . . . . . . . . . . . 8-31

Performance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-33

Live Editor Loop Execution: Improved performance when running loops in


live scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-33
Live Editor Animation Output: Improved performance when animating plots
in live scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-33
datetime, duration, and calendarDuration Data Type Indexing: Improved
performance when assigning elements by subscripting . . . . . . . . . . . . 8-34

xxxiv Contents
datetime Data Type Format Parsing: Improved performance when parsing
format of text inputs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-35
table Data Type Indexing: Improved performance when assigning elements
by subscripting into table variables . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-35
Subscripted Reference: Improved performance for struct arrays stored in a
property of an object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-36
imread Function: Improved performance in reading JPEG images . . . . . . 8-37
readmatrix Function: Improved performance in reading data . . . . . . . . . 8-37
ode15s, ode23t, and ode15i Solvers: Improved performance solving
differential equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-38
transpose and ctranspose Functions: Improved performance on large arrays
..................................................... 8-39
ordschur and ordqz Functions: Improved performance operating on large
matrices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-39
sparse Function: Improved performance constructing sparse matrices . . 8-40
interp1 Function: Faster interpolation for small problem sizes . . . . . . . . 8-40
assert Function: Improved performance for most common use cases . . . . 8-41
nexttile Function: Improved performance when creating several axes in a
tiled chart layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-41
App Designer Code View: Improved performance when displaying and
editing code in App Designer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-42
Graphics Rendering in UI Figures: Improved graphics rendering
performance on large data sets in UI figures . . . . . . . . . . . . . . . . . . . . 8-43
Data Tip Markers: Improved rendering performance of data tip markers in
line plots of large data sets created in UI figures and MATLAB Online
..................................................... 8-45
Icon Property: Improved rendering performance for buttons and tree nodes
with icons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-45
Functionality being removed or changed . . . . . . . . . . . . . . . . . . . . . . . . 8-46

Software Development Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-47

Dependency Analyzer: Improved navigation, filtering, and highlighting for


project dependencies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-47
Project Checks: Run all project checks programmatically . . . . . . . . . . . . 8-48
Project API: Get latest Git revision programmatically . . . . . . . . . . . . . . . 8-48
Unit Testing Framework: Add custom details to TestResult objects . . . . . 8-49
Unit Testing Framework: Assert that test session ran with no failure . . . 8-49
Unit Testing Framework: Run tests from the Live Editor toolstrip . . . . . . 8-49
Unit Testing Framework: Generate test reports including test tags . . . . . 8-49
App Testing Framework: Perform press gestures with different selection
types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-49
Mocking Framework: Add events to mock objects . . . . . . . . . . . . . . . . . . 8-49
Mocking Framework: Specify when framework should do nothing . . . . . 8-50
Functionality being removed or changed . . . . . . . . . . . . . . . . . . . . . . . . 8-50

External Language Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-51

C++ Interface: MATLAB data type for C++ array and std::vector . . . . . . 8-51
C++ Interface: Supported data types . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-51
C++ Interface: Lifetime management of C++ objects . . . . . . . . . . . . . . . 8-52
MATLAB Data Array: Support for N-D row-major memory layout . . . . . . 8-52
MATLAB COM Server: Register MATLAB without administrative privileges
..................................................... 8-52
Java interface: MATLAB support for OpenJDK™ 8 (Hot Spot) . . . . . . . . . 8-52

xxxv
Compiler support changed for building MEX files and standalone MATLAB
engine and MAT-file applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-52
Functionality being removed or changed . . . . . . . . . . . . . . . . . . . . . . . . 8-52

Hardware Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-54

MATLAB Support Package for Ryze Tello Drones: Control Ryze Tello drone
from MATLAB and acquire sensor and image data . . . . . . . . . . . . . . . 8-54
Support added for Raspberry Pi 4B model board . . . . . . . . . . . . . . . . . . . 8-54
Deploy deep learning applications on Raspberry Pi hardware . . . . . . . . . 8-54
Read GPS Data from GPS Receiver Connected to Arduino Hardware . . . . 8-54
Use BNO055 Sensor with Sensor Fusion and Tracking Toolbox, and
Navigation Toolbox to Estimate Orientation . . . . . . . . . . . . . . . . . . . . 8-55
Enable Code Generation of MATLAB Arduino Functions Inside a MATLAB
Function Block for I2C and SPI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-55
Functionality being changed or removed . . . . . . . . . . . . . . . . . . . . . . . . 8-55

R2019b

Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-2

Live Editor Tasks: Add interactive tasks to live scripts to explore parameters
and automatically generate code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-2
Live Editor Output: Animate plots to show changes in data over time . . . . 9-4
Live Editor Output: Adjust the width of columns in tables . . . . . . . . . . . . . 9-4
Live Editor Output: Scroll through and copy data in arrays such as cell
arrays, object arrays, and struct arrays . . . . . . . . . . . . . . . . . . . . . . . . . 9-4
Live Editor Export: Customize figure format as well as document paper size,
orientation, and margins when exporting . . . . . . . . . . . . . . . . . . . . . . . 9-5
Live Editor Code: Duplicate one or more lines of code . . . . . . . . . . . . . . . . 9-5
Live Editor Code: Suppress Code Analyzer warning messages . . . . . . . . . 9-6
Live Editor Debugging: Set breakpoints for anonymous functions . . . . . . . 9-6
Live Editor Internationalization: Add non-English language such as Chinese,
Japanese, and Korean characters on Windows and macOS Platforms . . . 9-6
Add-On Manager: Update MATLAB and other installed add-ons . . . . . . . . 9-6
Add-On Manager: Programmatically manage add-ons by name . . . . . . . . . 9-6
Settings: Create persistent settings for custom apps, toolboxes, and across
MATLAB sessions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-7
MATLAB Drive: Share folders and collaborate with others from MATLAB
...................................................... 9-7
MATLAB Drive: Upload folders from MATLAB to MATLAB Drive online
(October 2019) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-7
Functionality being removed or changed . . . . . . . . . . . . . . . . . . . . . . . . . 9-7

Language and Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-8

size Function: Find lengths of multiple array dimensions at a time . . . . . . 9-8


matches Function: Determine if input strings are equal . . . . . . . . . . . . . . 9-8
Hexadecimal and Binary Numbers: Specify numbers using hexadecimal and
binary literals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-8
Indexing: Use dot indexing into function calls . . . . . . . . . . . . . . . . . . . . . . 9-8

xxxvi Contents
System object authoring improvements: Property validation support and
simplified class inheritance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-8
Function Input Arguments: Declare function input arguments to restrict
values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-9
namedargs2cell Function: Convert structure containing name-value pairs to
cell array . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-9
delete, dir, isfile, isfolder, and what Functions: Access web-based storage
services like Amazon Web Services and Azure Blob Storage . . . . . . . . . 9-9
Suggested Corrections: Correct errors with two new classes . . . . . . . . . . 9-9
error Function: Provide suggested fix for uncaught exception . . . . . . . . . . 9-9
Functionality being removed or changed . . . . . . . . . . . . . . . . . . . . . . . . . 9-9

Data Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-14

Live Editor Tasks: Interactively preprocess data and generate code . . . . 9-14
groupfilter Function: Filter data in a table, timetable, or matrix by group
..................................................... 9-14
datetime Data Type: Detect formats with fractional seconds when
converting text that represents dates and times . . . . . . . . . . . . . . . . . 9-15
table and timetable Data Types: Variable names can have any characters,
including spaces and non-ASCII characters . . . . . . . . . . . . . . . . . . . . . 9-15
tall Arrays: Operate on tall arrays with more functions, including setdiff,
xcorr, and outerjoin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-16
tall Arrays: Avoid running out of memory due to temporary copies of data
..................................................... 9-17

Data Import and Export . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-18

detectImportOptions Function: Specify the type of import options for


delimited or fixed-width text files . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-18
table and timetable Data Types: Read and write tabular data that has
variable names containing any characters, including spaces and non-
ASCII characters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-18
sheetnames Function: Get names of worksheets from spreadsheet file . . 9-18
VideoReader Object: Read frames in videos using frame index or time . . 9-18
VideoReader Object: Improved performance in generated code with row-
major layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-19
Import Tool: Generate simpler code when importing from fixed-width text
files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-20
save Function: Save workspace variables to a MAT-file version 7 without
compression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-20
xmlread Function: Prevent reading of XML files that contain DOCTYPE
declarations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-20
imread Function: Supports reading specified images from PGM, PBM, or
PPM file formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-20
Scientific File Format Libraries: CFITSIO Library upgraded to version 3.450
..................................................... 9-20
Scientific File Format Libraries: LibTIFF Library upgraded to version 4.0.10
..................................................... 9-21
RESTful Functions: Support for authentication . . . . . . . . . . . . . . . . . . . . 9-21
tcpclient, read, and write Functions: Generate C and C++ code . . . . . . . 9-21
Bluetooth Low Energy Interface: Support for scanning and interacting with
peripheral devices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-21
Serial Port Devices: New functions and properties . . . . . . . . . . . . . . . . . 9-21
Functionality being removed or changed . . . . . . . . . . . . . . . . . . . . . . . . 9-22

xxxvii
Mathematics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-26

makima Function: Perform modified Akima cubic Hermite interpolation


..................................................... 9-26

Graphics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-27

Chart Container Class: Develop your own class of charts . . . . . . . . . . . . 9-27


tiledlayout and nexttile Functions: Create configurable layouts of plots in a
figure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-27
colororder Function: Control the colors in plots . . . . . . . . . . . . . . . . . . . 9-28
Bar Charts: Create bar charts with improvements for stacking and locating
the tips of bars . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-28
Data Tips: Create and customize data tips . . . . . . . . . . . . . . . . . . . . . . . 9-28
dataTipInteraction Function: Pin data tips at cursor location . . . . . . . . . 9-29
Axes Toolbar: Save or copy contents of axes as image . . . . . . . . . . . . . . . 9-29
parallelplot Function: Zoom, pan, and rearrange coordinates interactively
..................................................... 9-29
Property Inspector: Update axis tick values and labels using clipboard data
..................................................... 9-29
Image Interpolation: Select an interpolation method for displaying images
..................................................... 9-30
legend Function: Create unlimited legend entries and specify categorical
arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-30
pcolor Function: Specify categorical, datetime, and duration data . . . . . . 9-30
Geographic Plots: Plot data on high-zoom-level basemaps . . . . . . . . . . . . 9-30
Geographic Plots: Create plots with improved basemap appearance . . . . 9-31
Geographic Axes: Display animations using comet or animatedline . . . . . 9-32
Geographic Bubble Charts: Create charts with improved layout . . . . . . . 9-32
Functionality being removed or changed . . . . . . . . . . . . . . . . . . . . . . . . 9-32

App Building . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-36

uistyle Function: Create styles for rows, columns, or cells in a table UI


component . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-36
uigridlayout Function: Configure grid rows and columns to adjust
automatically to fit components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-36
uitable Function: Sort table UI components interactively when using logical,
numeric, string, or cell arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-36
uihtml Function: Embed HTML, JavaScript, or CSS content in apps and on
the App Designer canvas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-36
App Designer: Convert components in a UI figure or container from pixel-
based positioning to a grid layout manager . . . . . . . . . . . . . . . . . . . . . 9-37
App Designer: Convert an existing app into an auto-reflowing app . . . . . 9-37
App Designer: Suppress Code Analyzer warning messages . . . . . . . . . . . 9-37
App Designer: Open App Designer from the MATLAB toolstrip . . . . . . . . 9-38
App Testing Framework: Perform gestures on polar axes and UI images
..................................................... 9-38
Functionality being removed or changed . . . . . . . . . . . . . . . . . . . . . . . . 9-38

Performance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-41

table Data Type Indexing: Improved performance when assigning elements


by subscripting into large table variables . . . . . . . . . . . . . . . . . . . . . . 9-41

xxxviii Contents
datetime, duration, and calendarDuration Data Type Indexing: Improved
performance when assigning elements by subscripting into large arrays
..................................................... 9-42
datetime Data Type Indexing: Improved performance when referring or
assigning to date and time components of datetime arrays . . . . . . . . . 9-43
uitable Function: Faster performance when data type is numeric, logical, or
a cell array of character vectors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-44
unzip and gunzip Functions: Improved performance when extracting
contents of zip files and GNU zip files . . . . . . . . . . . . . . . . . . . . . . . . . 9-44

Software Development Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-46

Unit Testing Framework: Run tests in parallel with your custom plugins
..................................................... 9-46
Unit Testing Framework: Validate count in string constraints . . . . . . . . . 9-46
Performance Testing Framework: Visually compare two TimeResult arrays
..................................................... 9-46
App Testing Framework: Perform gestures on polar axes and images . . . 9-46
Projects: Delete project definition files . . . . . . . . . . . . . . . . . . . . . . . . . . 9-47
Compare Git Branches: Show differences and save copies . . . . . . . . . . . . 9-47
Functionality being removed or changed . . . . . . . . . . . . . . . . . . . . . . . . 9-47

External Language Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-48

C++ Interface: Options for publishing C++ interface library . . . . . . . . . 9-48


C++ Interface: nullptr supported as output argument . . . . . . . . . . . . . . 9-48
C++ Interface: Read-only (const) object support . . . . . . . . . . . . . . . . . . . 9-48
Java Interface: JRE version 1.8.0_202 support . . . . . . . . . . . . . . . . . . . . . 9-48
Out-of-Process Execution of C++ MEX Functions: Customize environment
variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-48
HTTP Web Services: Server authentication support for NTLM and Kerberos
protocols . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-48
HTTP Web Services: Timeout options . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-49
Python Interface: Execute Python functions out of process . . . . . . . . . . . 9-49
Python Interface and Engine: Version 3.5 support discontinued . . . . . . . 9-49
Perl 5.30.1: MATLAB support on Windows . . . . . . . . . . . . . . . . . . . . . . . 9-49
Compiler support changed for building MEX files and standalone MATLAB
engine and MAT-file applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-50
Functionality being removed or changed . . . . . . . . . . . . . . . . . . . . . . . . 9-50

R2019a

Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-2

Live Editor Controls: Add check boxes, edit fields, and buttons to set
variable values and run the live script . . . . . . . . . . . . . . . . . . . . . . . . . 10-2
Live Editor Controls: Specify what code to run when a control value
changes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-2
Live Editor Controls: Hide code when sharing and exporting live scripts
with interactive controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-2
Live Editor Export: Save live scripts and functions as Microsoft Word
documents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-2

xxxix
Live Editor Output: Enable animations in plots to show changes in data over
time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-3
Live Editor Output: Interactively clean categorical data and filter datetime
and duration variables in table output . . . . . . . . . . . . . . . . . . . . . . . . . 10-4
Live Editor Output: Interactively change the data type of variables in table
output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-4
Live Editor Functions: Automatically convert selected code to a function
..................................................... 10-5
MATLAB Online: Share folders and collaborate with others . . . . . . . . . . . 10-5
Projects: Organize, manage, and share your work using projects . . . . . . 10-5
MATLAB Startup: Execute MATLAB script or function non-interactively
..................................................... 10-5
Toolbox Packaging: Install required add-ons with custom toolboxes . . . . 10-6
MATLAB Drive: View MATLAB files in MATLAB Drive Online (April 2019)
..................................................... 10-6
MATLAB Drive: Improvements to MathWorks account sign on (May 2019)
..................................................... 10-6

Language and Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-7

append Function: Combine strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-7


MException class: Provide a suggested fix for an uncaught exception . . . 10-7
Functionality being removed or changed . . . . . . . . . . . . . . . . . . . . . . . . 10-7

Data Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-10

xcorr and xcov Functions: Compute cross-correlation and cross-covariance


in core MATLAB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-10
detrend Function: Remove piecewise polynomial trends, set continuity
requirements, and specify sample points . . . . . . . . . . . . . . . . . . . . . 10-10
groupcounts Function: Count the number of group elements for arrays,
tables, and timetables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-10
grouptransform Function: Transform array data by group . . . . . . . . . . 10-10
filloutliers, isoutlier, and rmoutliers Functions: Detect outliers using
percentiles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-10
fillmissing and filloutliers Functions: Fill missing and outlier data using
modified Akima interpolation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-10
fillmissing Function: Specify missing value locations . . . . . . . . . . . . . . . 10-10
min and max Functions: Return index information when operating on more
than one dimension and specify linear indices . . . . . . . . . . . . . . . . . . 10-11
tall Arrays: Write custom sliding-window algorithms to operate on tall
arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-11
tall Arrays: Operate on tall arrays with more functions, including
groupcounts, intersect, and svd . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-11
Functionality Being Removed or Changed . . . . . . . . . . . . . . . . . . . . . . . 10-12

Data Import and Export . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-13

readmatrix, readvars, and readcell Functions: Read tabular data as a


matrix, variables, or a cell array . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-13
writematrix and writecell functions: Write tabular data from a matrix or cell
array to a text or spreadsheet file . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-13
readtimetable and writetimetable Functions: Read and write timetables
.................................................... 10-13
detectImportOptions Function: Improve detection of import options for text
and spreadsheet files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-13

xl Contents
parquetread, parquetwrite, and parquetinfo Functions: Read, write, and get
information from Parquet files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-14
write Function: Write tall arrays to Parquet files . . . . . . . . . . . . . . . . . . 10-14
Import Tool: Generate improved code when importing from text files . . 10-14
thingSpeakRead and thingSpeakWrite Functions: Read or write data to the
ThingSpeak IoT platform . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-14
writetable and imwrite Functions: Write to web-based storage services like
Amazon Web Services and Azure Blob Storage . . . . . . . . . . . . . . . . . 10-14
ParquetDatastore Object: Create a datastore for a collection of Parquet files
.................................................... 10-15
ImageDatastore Object: Create a subset of an existing datastore . . . . . 10-15
DsFileSet Object: Create a subset of a file collection . . . . . . . . . . . . . . . 10-15
FileDatastore Object: Read large files by importing the file in smaller
portions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-15
Datastores: Combine and transform datastores . . . . . . . . . . . . . . . . . . . 10-15
Custom Datastore: Read Hadoop based data from files, databases, and other
non-file-based locations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-15
VideoReader function: Generate C and C++ code . . . . . . . . . . . . . . . . . 10-15
ind2rgb function: Generate C and C++ code . . . . . . . . . . . . . . . . . . . . 10-16
Scientific File Format Libraries: NetCDF Library upgraded to version 4.6.1
.................................................... 10-16
web function: Open external sites in system browser instead of MATLAB
browser . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-16
Functionality being removed or changed . . . . . . . . . . . . . . . . . . . . . . . 10-16

Mathematics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-19

Solve assignment problem with matchpairs and equilibrate . . . . . . . . . 10-19


graph and digraph Objects: Construct graphs with categorical nodes . . 10-19

Graphics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-20

parallelplot Function: Visualize tabular or matrix data with multiple


columns by using a parallel coordinates plot . . . . . . . . . . . . . . . . . . . 10-20
Data Tips: Pin and customize data tips in charts . . . . . . . . . . . . . . . . . . 10-20
Axes Interactions: Customize chart interactions such as dragging to pan or
scrolling to zoom . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-20
Ruler Panning: Pan an axis to change its limits without having to use the
pan tool . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-21
Property Inspector: Navigate and control visibility of graphics objects
interactively . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-21
Geographic Plots: Geographic rulers, scale bar, CurrentPoint, and ginput
.................................................... 10-21
Graphics Export: Export axes with tighter cropping using the axes toolbar
.................................................... 10-22
Chart Resizing: Resize charts with improved layouts . . . . . . . . . . . . . . 10-22
Colors Values: Specify colors using hexadecimal color codes . . . . . . . . . 10-23
Categorical Values: Specify categorical arrays for functions and objects that
use lists of text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-23
rendererinfo Function: Get renderer information for any axes . . . . . . . . 10-23
Functionality being removed or changed . . . . . . . . . . . . . . . . . . . . . . . 10-23

App Building . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-25

uiimage Function: Display an icon, logo, or picture in apps and on the App
Designer canvas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-25

xli
uitable Function: Sort tables interactively when using table arrays . . . . 10-25
Auto Resize: Automatically resize components when an app is made smaller
.................................................... 10-25
Scrolling Grids: Create apps with scrollable grids . . . . . . . . . . . . . . . . . 10-25
App Designer: Create apps that automatically reflow content based on
device size . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-25
App Designer: Add and configure a grid layout manager on the App
Designer canvas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-25
App Designer: Rearrange the order of callbacks . . . . . . . . . . . . . . . . . . 10-26
App Designer: Create new apps using App Designer Start Page options
.................................................... 10-26
App Designer: Control font, code, and autosave settings using MATLAB
Preferences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-26
App Designer: Access context-sensitive help in Code View . . . . . . . . . . 10-26
App Designer: Zoom in App Designer . . . . . . . . . . . . . . . . . . . . . . . . . . 10-26
Graphics Support: Explore data using axes toolbar and data tips in apps
created with the uifigure function . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-27
Deployed Web Apps: Share resizeable apps or create apps that open web
pages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-27
MATLAB Online: Create and edit App Designer apps using MATLAB Online
.................................................... 10-27
App Testing Framework: Perform hover gesture on axes, UI axes, and UI
figures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-27
App Testing Framework: Perform press gesture on axes, UI axes, and UI
figures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-28
App Testing Framework: Perform type gesture on date picker objects . . 10-28
Functionality Being Removed or Changed . . . . . . . . . . . . . . . . . . . . . . . 10-28

Performance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-29

MATLAB and Simulink startup on macOS platforms . . . . . . . . . . . . . . . 10-29


sortrows Function: Sort rows of large matrices faster . . . . . . . . . . . . . . 10-29
uitable Function: Faster performance using table arrays . . . . . . . . . . . . 10-29

Software Development Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-30

checkcode Function: Get the modified cyclomatic complexity of functions


.................................................... 10-30
Source Control Integration: Synchronise MATLAB Git status with external
Git clients . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-30
Unit Testing Framework: Display code coverage metrics in HTML format
.................................................... 10-30
Unit Testing Framework: Specify sources for collections of code coverage
data with runtests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-30
Unit Testing Framework: runperf collects more samples to achieve its target
margin of error . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-30
Unit Testing Framework: Return performance test results as TimeResult
arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-30
Unit Testing Framework: Load previously saved MeasurementResult objects
as DefaultMeasurementResult . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-31
Unit Testing Framework: Use matlab.unittest.fixtures.Fixture.onFailure
method only in subclasses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-31
Unit Testing Framework: Compare tables that contain no rows . . . . . . . 10-31
Unit Testing Framework: Create test suite array from tests in project . . 10-32
Unit Testing Framework: Run tests from files in project using runtests or
testsuite . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-32

xlii Contents
Unit Testing Framework: Specify verbosity enumeration as a string or
character vector . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-32
App Testing Framework: Perform hover gesture on axes, UI axes, and UI
figures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-32
App Testing Framework: Perform press gesture on axes, UI axes, and UI
figures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-32
App Testing Framework: Perform type gesture on date picker objects . . 10-32
Mocking Framework: Create mocks for classes that use custom metaclasses
.................................................... 10-32
Mocking Framework: Create mocks for classes that use property validation
.................................................... 10-33
Mocking Framework: Specify which methods to mock . . . . . . . . . . . . . 10-33
Functionality being removed or changed . . . . . . . . . . . . . . . . . . . . . . . 10-33

External Language Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-34

C++: Use C++ classes from third-party libraries in MATLAB . . . . . . . . 10-34


Python: Version 3.7 support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-34
Python engine: Data type support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-34
C++ MEX: Execute MEX function out of process . . . . . . . . . . . . . . . . . 10-34
MEX functions: Use customer version of Boost library . . . . . . . . . . . . . 10-34
MATLAB Data Array: Support for row-major memory layout . . . . . . . . . 10-34
Compiler support changed for building MEX files and standalone MATLAB
engine and MAT-file applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-35

Hardware Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-36

MATLAB Support Package for Parrot Drones: Control Parrot Mambo FPV
drone from MATLAB and acquire sensor data . . . . . . . . . . . . . . . . . . 10-36
Deploy Sense HAT functions on Raspberry Pi hardware . . . . . . . . . . . . 10-36
Functionality being changed or removed . . . . . . . . . . . . . . . . . . . . . . . 10-36

R2018b

Desktop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-2

Live Editor: Organize live scripts using additional subheading styles . . . 11-2
Live Editor: Navigate within a live script using internal hyperlinks . . . . . 11-2
Live Editor: Filter table output interactively, and then add the generated
code to the live script . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-2
Live Editor: Create new and open existing live scripts faster . . . . . . . . . . 11-2
Live Editor: Change case of text or code . . . . . . . . . . . . . . . . . . . . . . . . . 11-2
Comparison Tool: Merge two versions of a live script or function . . . . . . 11-3
Add-On Manager: Install and manage multiple versions of a custom toolbox
..................................................... 11-3
Add-On Manager: Save add-ons to new default location . . . . . . . . . . . . . 11-3
Documentation: View MATLAB documentation in Spanish . . . . . . . . . . . . 11-4
MATLAB Drive: Install and start MATLAB Drive Connector from inside
MATLAB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-4
MATLAB Drive: Improved performance when syncing files in MATLAB Drive
Connector . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-4

xliii
MATLAB Drive: Share and collaborate in MATLAB Drive online (December
2018) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-4
MATLAB Drive: View shared status of files in MATLAB Drive Connector
(February 2019) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-4

Language and Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-6

string Arrays: Use string arrays in MATLAB, Simulink, and Stateflow . . . 11-6
convertContainedStringsToChars Function: Convert string arrays at any
level of cell array or structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-6
Enumerations: Improved performance of set operations with enumerations
..................................................... 11-6
WSDL Web Services Documents: Required Tools Update . . . . . . . . . . . . . 11-6
Functionality being removed or changed . . . . . . . . . . . . . . . . . . . . . . . . 11-6

Mathematics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-8

boundaryshape Function: Create a polyshape object from a 2-D


triangulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-8
polyshape Objects: Specify when to keep collinear points when creating a
polyshape . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-8
RandStream Objects: Generate random numbers using Threefry and Philox
algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-8
GraphPlot Object: Customize node and edge labels with font properties
..................................................... 11-8
sinpi and cospi Functions: Compute the sine and cosine of multiples of π
..................................................... 11-9

Graphics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-10

Axes Interactions: Explore data with panning, zooming, data tips, and 3-D
rotation enabled by default . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-10
Axes Toolbar: Access and customize a data exploration toolbar for each Axes
object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-10
Geographic Plots: Create line, scatter, and point density plots on interactive
maps and control properties of a geographic axes . . . . . . . . . . . . . . . 11-10
stackedplot Function: Plot variables of a table or timetable for comparison
using a common x-axis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-11
scatterhistogram Function: Visualize grouped data as a scatter plot with
marginal histograms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-11
sgtitle Function: Create a title for a grid of subplots . . . . . . . . . . . . . . . 11-11
xline and yline Functions: Add vertical or horizontal lines to a plot . . . . 11-11
imtile Function: Combine multiple image frames into one rectangular tiled
image . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-12
Data Tips: Use TeX or LaTeX markup in data tips with improved visual
appearance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-12
Functionality being removed or changed . . . . . . . . . . . . . . . . . . . . . . . 11-13

Data Import and Export . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-14

Import Tool: Generate improved code when importing from spreadsheets


.................................................... 11-14
Web-Based Data: Read from web-based data sources like Amazon Web
Services and Azure Blob Storage using readtable, detectImportOptions,
spreadsheetDatastore, imread, and imfinfo . . . . . . . . . . . . . . . . . . . . 11-14

xliv Contents
write Function: Write tall arrays in a variety of formats to local or remote
locations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-14
stlread and stlwrite Functions: Read from and write to STL
(Stereolithography) files for triangulations . . . . . . . . . . . . . . . . . . . . 11-15
TabularTextDatastore Object: Import data containing dates and times from
non-English locales . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-15
readtable and writetable Functions: Read or write spreadsheet files without
initiating Microsoft Excel for Windows on Windows platforms . . . . . . 11-15
readtable Function: Manage the import of empty fields using import options
.................................................... 11-15
Scientific File Format Libraries: CFITSIO Library upgraded to version 3.420
.................................................... 11-15
Functionality being removed or changed . . . . . . . . . . . . . . . . . . . . . . . 11-15

Data Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-18

Vector Dimension Argument: Operate on multiple dimensions at a time for


selected reduction functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-18
grouptransform Function: Transform table or timetable data by groups
.................................................... 11-18
groupsummary Function: Perform group summary computations on
matrices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-18
tall Arrays: Write custom algorithms to operate on tall arrays . . . . . . . . 11-18
tall Arrays: Operate on tall arrays with more functions, including conv2,
wordcloud, and groupsummary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-19
rmoutliers Function: Remove outliers in an array, table, or timetable . . 11-19
islocalmin and islocalmax Functions: Specify a range of data for prominence
computation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-19
Table and Timetable Metadata: Store custom metadata for each variable
.................................................... 11-20
timetable Data Type: Save memory when storing row times with regular
time steps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-20
timerange Function: Specify unit of time to define time range . . . . . . . 11-20
convertvars Function: Convert table or timetable variables to specified data
type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-20
table, timetable, and addvars Functions: Use single quotes for input names,
not double-quoted strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-20
Functionality Being Removed or Changed . . . . . . . . . . . . . . . . . . . . . . . 11-20

App Building . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-22

App Designer: Add and configure date selection components on the App
Designer canvas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-22
App Designer: Unified property inspector in Design View and Code View
.................................................... 11-22
App Designer: Expand and collapse sections of code in Code View . . . . 11-22
App Designer: Export apps as code files . . . . . . . . . . . . . . . . . . . . . . . . 11-22
App Designer: Locate errors and warnings in your code with the Code
Analyzer message bar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-22
App Designer: Program apps faster using improved code suggestions and
completions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-22
App Designer: Control App Designer Code View settings using MATLAB
preferences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-22
uigridlayout Function: Configure app layouts using a grid layout manager
.................................................... 11-23

xlv
Scrolling Containers: Enable scrolling for figure, panel, tab, and button
group containers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-23
Figure Interactions: Create apps with custom mouse and keyboard
interactions using figures created with the uifigure function . . . . . . . 11-23
Graphics Support: Integrate plots into an app using the axes, polaraxes, and
geoaxes functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-23
Tooltips: Create custom tooltips for UI components in apps . . . . . . . . . 11-23
Deployed Web Apps: Access files in deployed web apps using the uigetfile
and uiputfile functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-24
Running Apps in Browsers: Use most modern browsers to run apps in
MATLAB Online or as deployed web apps . . . . . . . . . . . . . . . . . . . . . 11-24
uisetcolor Function: Select custom colors interactively . . . . . . . . . . . . . 11-24
Functionality Being Removed or Changed . . . . . . . . . . . . . . . . . . . . . . . 11-24

Performance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-25

Startup: Increased speed of MATLAB startup . . . . . . . . . . . . . . . . . . . . 11-25


Execution Engine: Index into large arrays with improved performance when
using the colon operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-25
Execution Engine: Faster calls to built-in functions . . . . . . . . . . . . . . . . 11-25
Live Editor: Create new and open existing live scripts faster . . . . . . . . . 11-25
Enumerations: Improved set function performance with enumerations
.................................................... 11-25
Building Apps: Faster canvas interactions in App Designer . . . . . . . . . . 11-25
Running Apps: Faster startup time for apps . . . . . . . . . . . . . . . . . . . . . 11-25
sort Function: Sort matrices and arrays faster . . . . . . . . . . . . . . . . . . . 11-25

Hardware Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-26

MATLAB Online: Communicate with Raspberry Pi hardware board from


MATLAB Online . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-26
Deploy a MATLAB function on Raspberry Pi hardware . . . . . . . . . . . . . 11-26
iOS and Android Sensors: Acquire sensor data when your device does not
have network access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-26
iOS and Android Sensors: Upload sensor logs from the device to MATLAB
Drive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-27

Advanced Software Development . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-28

Tab Completion: Validate function signature file with


validateFunctionSignaturesJSON function . . . . . . . . . . . . . . . . . . . . 11-28
Tab Completion: JSON parser for functionSignatures.json upgrade . . . . 11-28
Java SE 8: MATLAB support, providing improved security and access to new
Java features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-28
Python Interface: Pass multidimensional numeric or logical arrays between
MATLAB and Python . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-28
C++ MEX API: Call MATLAB asynchronously from within a MEX file using
the C++ API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-28
Unit Testing Framework: Run tests in parallel with more plugins and more
intelligent scheduling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-29
Unit Testing Framework: Use external parameters in parameterized test
.................................................... 11-29
Unit Testing Framework: Sort test suite based on shared fixtures . . . . . 11-29
Unit Testing Framework: Explicitly control output display detail and logged
diagnostic level . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-29
Unit Testing Framework: Configure detail level of output diagnostics . . 11-30

xlvi Contents
Unit Testing Framework: Compare values faster when using constraints
.................................................... 11-30
App Testing Framework: Programmatically choose tree node . . . . . . . . 11-31
Performance Testing Framework: Measure execution time of fast code more
accurately with the TestCase.keepMeasuring method . . . . . . . . . . . . 11-31
Mocking Framework: Invoke function upon mocked method call . . . . . . 11-31
Mocking Framework: Verify interactions on mock occurred in order . . . 11-31
Mocking Framework: Clear history of recorded mock object interactions
.................................................... 11-31
matlab.test.behavior.Missing class: Verify class satisfies missing-value
behavior contract . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-31
MEX Functions: Build Fortran MEX Files with Interleaved Complex API
.................................................... 11-32
Compiler support changed for building MEX files and standalone MATLAB
engine and MAT-file applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-32
System objects: Flexible requirements for inputs when calling System
objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-33
System object authoring: Use enumerations to define finite property lists in
System objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-33
Reference Architecture: Deploy and run MATLAB on Amazon Web Services
(AWS) and Microsoft Azure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-33
Git Stashes: Store uncommitted changes for later use . . . . . . . . . . . . . 11-33
Functionality being removed or changed . . . . . . . . . . . . . . . . . . . . . . . 11-33

xlvii
1

R2023b

Version: 23.2

New Features

Bug Fixes

Compatibility Considerations
R2023b

Environment
Live Editor Tasks: Create Live Editor task from selected code with
interactive controls
You can convert a selection in the Live Editor that contains code, text, and interactive controls into
your own Live Editor task. Supported controls include numeric sliders, numeric spinners, drop-down
lists, check boxes, edit fields, buttons, and file browsers.

To create your own Live Editor task from a selection, after making the selection, go to the Live
Editor tab, and in the Code section, select Task > Convert to Task. When prompted, enter a name
for the task, the name of the task class definition file to create, an optional description of the task,
and some optional keywords. MATLAB creates your Live Editor task from the selection and adds the
task to the Live Editor task gallery.

To add your task to a live script, on the Live Editor tab, click Task and select your task from the list.

For more information, see “Create Live Editor Task from Selection”.

Live Editor Tables: Add tables containing text and images to live
scripts and functions
You can add tables to your live scripts and functions to format text and images. To insert a table, go to
the Insert tab and select Table . Move the cursor over the grid to highlight the numbers of rows
and columns you want and then click to add the table. To create a larger table, select the Insert a

table button and specify the numbers of rows and columns in the dialog box.

After inserting the table, to modify its rows and columns, right-click the table, select Table, and
select from the available options. For more information, see “Format Text in the Live Editor”.

Live Editor Controls: Add color pickers and state buttons to live
scripts
You can add a color picker to your live script to select a color interactively. You also can add a state
button to indicate and interactively set the value of a logical variable.

1-2
Environment

To add a color picker, go to the Live Editor tab, and in the Code section, select Control > Color
Picker. To add a state button, select State Button.

For more information, see “Add Interactive Controls to a Live Script”.

Live Editor Controls: Select folders interactively in live scripts using


file browser
You can use a file browser in a live script to select a folder interactively. To add a file browser, go to
the Live Editor tab, and in the Code section, select Control > File Browser. To configure the
control to select a folder rather than a file, right-click the control and select Configure Control.
Then, in the Type section, select Folder.

For more information, see “Add Interactive Controls to a Live Script”.

Live Editor Accessibility: Interact with inline output using the


keyboard
You can now use keyboard shortcuts to interact with inline output in live scripts. To move focus from
the code to the output, use the down arrow and up arrow keys. To activate an output, press Enter.
Once an output is activated, you can scroll text using the arrow keys, navigate through hyperlinks
and buttons using the Tab key, and open the context menu by pressing Shift+F10. To deactivate an
output, press Esc.

To disable using the keyboard to move focus to the output when output is inline, on the Home tab, in
the Environment section, click Preferences. Select MATLAB > Editor/Debugger > Display,
and clear the Focus outputs using keyboard when output is inline option.

Live Editor Export: Interactively customize export options, such as


document paper size, orientation, margins, and figure format
When exporting to PDF, Microsoft® Word documents, HTML, and LaTeX, you can use the Export
dialog box to customize export options interactively. To open the Export dialog box, on the Live
Editor tab, click Export and then select an export format. In MATLAB Online™, click Save instead of
Export.

You can change the paper size, orientation, and margins when exporting to PDF, Microsoft Word
documents, and LaTeX. You also can change the resolution and format of figures when exporting to
PDF, HTML, and LaTeX (requires the files to be run before exporting).

1-3
R2023b

For more information, see “Ways to Share and Export Live Scripts and Functions”.

export Function: Convert live scripts and functions to Markdown files


and Jupyter notebooks
You can convert live scripts and functions to Markdown files and Jupyter® notebooks by using the
export function. To convert a live script or function to a Markdown file or Jupyter notebook, specify
an output filename with a .md or .ipynb extension. Alternatively, you can set the Format name-
value argument to "Markdown" or "ipynb".

For example, convert the live script "penny.mlx" to a Markdown file and a Jupyter notebook.

export("penny.mlx","penny.md")
export("penny.mlx","penny.ipynb")

Editor Execution: Run sections even if other sections contain syntax


errors
In the Editor and Live Editor, you can now run a code section even if another section in the file
contains a syntax error. Previously, you could run a section only if the entire file contained no syntax
errors.

For more information about creating sections, see “Create and Run Sections in Code”.

Editor Variable Renaming: Automatically rename next references to


variables or functions in file
In the Editor and Live Editor, when you rename a variable or function in a file, you can choose
whether to rename all instances or only the instances from the current cursor location to the end of
the file. To rename all instances of a variable or function, press Shift+Enter. To rename only the
instances from the current cursor location to the end of the file, press Alt+Shift+Enter. On macOS,
use Option+Shift+Enter instead.

For more information, see “Find and Replace Text in Files and Go to Location”.

1-4
Environment

Find and Replace Dialog Box: Use capture groups in regular


expressions to search for and replace groups of characters
Search for and replace groups of characters in a file using capture groups in regular expressions. To
begin searching using regular expressions, on the Editor or Live Editor tab, in the Navigate

section, click Find. Then, select the Regular expression option .

To create a capture group, surround the characters that you want to group with parentheses. Then, to
access the capture group within the regular expression, use the format \number, where number
refers to the capture group number. To access the capture group within a replacement pattern, use
the format $number. For example, to find duplicate words in a file, use the expression (\w+)\s\1. To
replace the two words with just one word, use the expression $1.

You also can create a named capture group using the format ?<name>, where name is the name of the
capture group. Then, to access the named capture group, use the format \k<name> within the
regular expression, or $<name> within a replacement pattern. For example, to find duplicate words
using a named capture group, use the expression (?<myword>\w+)\s\k<myword>. To replace the
two words with just one word, use the expression $<myword>.

For more information about searching using the find and replace dialog box, see “Find and Replace
Text in Files and Go to Location”.

Debugging in MATLAB Online: Manage breakpoints and navigate the


function call stack using Debugger panel
Use the Debugger panel to manage breakpoints and navigate the function call stack while debugging
in MATLAB Online. To open the Debugger panel, go to the Editor or Live Editor tab, and in the
Analyze section, click Debugger. You also can open the panel using the Open more panels button
( ) in the sidebar.

1-5
R2023b

For more information, see “Debug MATLAB Code Files”.

Desktop Layout in MATLAB Online: Open additional panels directly


from sidebars
In MATLAB Online, you can open additional panels (also referred to as tools) directly from the
sidebars. To open additional panels, in a sidebar, click the Open more panels button ( ). Then, in the
Open Panel dialog box, select from the available panels. You also can right-click in a sidebar and
select Open more panels.

For example, to open the Code Issues panel, click the Open more panels button ( ), and select the
Code Issues panel.

For more information, see “Change Desktop Layout”.

Themes in MATLAB Online: Save color customizations for individual


themes
MATLAB Online now saves your color customizations for each available theme. If you customize the
colors of the MATLAB Online desktop and then the MATLAB theme changes to a new theme or to
match a change to the operating system color scheme, your customizations are saved.

With this change, in MATLAB Online, programmatically customizing syntax highlighting colors using
the matlab.colors settings is no longer supported. To customize syntax highlighting colors, use the
preferences in the MATLAB Appearance Colors Preferences page of the Preferences window
instead. For more information, see “Change Desktop Colors”.

In an installed version of MATLAB, programmatically customizing syntax highlighting colors using the
matlab.colors settings is still supported.

1-6
Environment

Window Management in MATLAB Online: Automatically collapse


windows
In MATLAB Online, when you click the MATLAB background, open windows in the foreground
collapse. Collapsing a window reduces the size of the window by displaying only its title bar.

To restore the collapsed windows, click the title bar of one of the previously open windows. To

prevent a window from being collapsed or minimized, click on its title bar.

For more information, see “Manage Windows in MATLAB Online”.

MATLAB on Macs: Better performance and improved battery life on


MacBooks with MATLAB and Simulink running natively on Apple silicon
You can run MATLAB and Simulink® natively on MacBook computers with Apple silicon.

MATLAB on Macs: Java Runtime Environment required for MATLAB and


MATLAB Runtime on Apple silicon
On Mac computers with Apple silicon, if MATLAB or MATLAB Runtime does not find a supported Java
Runtime Environment (JRE™), the program displays a dialog box with a link to information about the
Java® requirement and the recommended solution. For information about the recommended solution,
see https://www.mathworks.com/support/requirements/apple-silicon.html. For more
information, see “Start MATLAB on macOS Platforms”.

Functionality being removed or changed


MATLAB Online keyboard shortcuts Ctrl+0, Ctrl+1, Ctrl+2, and Ctrl+3 have been removed

The Ctrl+0, Ctrl+1, Ctrl+2, and Ctrl+3 keyboard shortcuts have been removed in MATLAB Online
to avoid a conflict with the shortcuts to switch tabs in certain browsers. These shortcuts were
previously used to make the Command Window, Command History, Files panel, or Workspace panel
active. On macOS, the corresponding keyboard shortcuts (Command+0, Command+1, Command
+2, and Command+3) have also been removed.

To make one of these tools active, use Ctrl+F6 and Ctrl+Shift+F6 to move forward or backward
through the different areas of the MATLAB Online desktop until your intended tool is selected. Then,
to navigate into the tool, press the Tab key. On macOS, use the Command key instead of the Ctrl
key.

XML comparison type for visdiff function will be removed


Warns

1-7
R2023b

The XML comparison type for the visdiff function will be removed in a future release. Overriding
the default comparison type by specifying "xml" will not be supported in a future release. In R2023b,
scripts that use visdiff(filename1,filename2,"xml") issue a warning.

1-8
Language and Programming

Language and Programming

configureDictionary Function: Create dictionaries with configured keys


and values
Use the configureDictionary function to create an empty dictionary with specified types for keys
and values.

For example, create a dictionary that is configured to accept strings as keys and doubles as values.

d = configureDictionary("string","double")

d =

dictionary (string ⟼ double) with no entries.

lookup, insert, and remove Functions: Find, add, and remove


dictionary entries
You can perform basic dictionary operations using these three new functions:

• lookup — Find the value that corresponds to a key. You can optionally specify a fallback value for
the function to return if it cannot find the entry.

• insert — Add new dictionary entries. You can optionally specify whether to overwrite existing
entries.

• remove — Remove dictionary entries.

codeIssues Object: Export issues identified in code


Use the export object function of the codeIssues object to write its issues to a file. Exported files
are in SARIF format by default, but you can specify to export issues in SonarQube or MATLAB
encoded JSON formats.

Code Compatibility Analyzer App: Group and filter code issues with
improved interface
The Code Compatibility Analyzer app has a new interface that makes it easier to navigate issues
found in code. You can now adjust how identified issues are grouped and filter results by text,
severity, and issue type.

1-9
R2023b

Class Diagram Viewer: Add known subclasses to diagrams


You can now automatically add one or more layers of known subclasses of a class in a diagram. Right-
click the class in a diagram to see the options for adding subclasses. See Class Diagram Viewer for
more information.

mustBeSparse Function: Validate sparsity of arguments


Use the mustBeSparse validation function to check whether an argument is sparse. This function is
designed for use in function argument validation and property validation.

1-10
Language and Programming

Functionality being removed or changed


Arrays contained in structure fields, cells, and class properties are displayed with partial
contents as well as size and data type
Behavior change

Between R2021b and R2023b, MATLAB displayed the entire contents of an array in a structure field,
cell, or class property if the contents fit in the display. If the array did not fit, MATLAB showed as
much of the array as the display allowed.

Starting in R2023b, if the entire contents of an array in a structure field, cell, or class property do not
fit in the display, MATLAB shows as much of the array as the display allows, as well as the size and
data type of the array. For example, as of R2023b, MATLAB displays partial contents as well as size
and data type for a cell that contains an array of 100 double values.
D = {3.14,[1:100]};
D(2)

ans =

1×1 cell array

{[1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 … ] (1×100 double)}

The disp function follows the same behavior for structures, cells, and class properties.

For more information, see the Version History notes in cell and struct.

Using the AbortSet attribute and a get method that sets the property value can cause
infinite recursion
Behavior change

Generally, MATLAB calls a property set method, if one exists, when a property is set outside of the set
method. When a property has a set method and uses the AbortSet attribute, MATLAB acquires the
old value and compares it with the new value for any assignment to that property outside of its set
method. If the property has a get method, the get method is called to acquire the old value.

For R2023b, the get method is no longer bypassed when it indirectly results in another call to the get
method because of the AbortSet check. This removes overhead from many property access
operations. As a result, MATLAB calls the get method again to acquire the old property value when a
property fits all three of these conditions:

• The property uses the AbortSet attribute.


• The property has a set method.
• The property has a get method that assigns a value to the property.

This call to get could lead to infinite recursion if the property assignment in the get method is
unconditional.

Malformed and reserved import arguments issue warning


Behavior change

Previously, the import function accepted malformed arguments, such as #.b or a.*.*, and MATLAB
still executed the command even though nothing was imported. It also allowed importing of reserved
names, such as a.for or a.if that do not satisfy MATLAB naming rules. Starting in R2023b,

1-11
R2023b

MATLAB issues a warning if you include invalid imports. Such imports will not be supported in a
future release.

ver and verlessthan are not recommended


Still runs

Using ver to return the current MATLAB release information is not recommended. Use
matlabRelease instead.

Using verlessthan to determine if the current MATLAB release is older than a specified release is
not recommended. Use isMATLABReleaseOlderThan instead.

Defining classes and packages: Using schema.m will not be supported in a future release
Still runs

Support for classes and packages defined using schema.m files will be removed in a future release.
Replace existing schema-based classes with classes defined using the classdef keyword.

1-12
Data Analysis

Data Analysis

Experiment Manager App: Design experiments to run MATLAB code,


and visualize, filter, and compare results
Create an experiment to run your MATLAB code using a range of parameter values and compare the
results by using the Experiment Manager app. For example, you can use an experiment to explore
how the solution to a system of differential equations responds to different coefficient values or how it
evolves from different initial conditions. When you run the experiment, Experiment Manager runs
your code in multiple trials, each one using a different combination of parameter values.

Experiment Manager provides visualizations, filters, and annotations to help you manage your
experiment results and record your observations. To improve reproducibility, Experiment Manager
stores a copy of the experiment definition every time that you run an experiment. You can access past
experiment definitions to keep track of the parameter values and MATLAB code that produce each of
your results.

By default, Experiment Manager runs one trial at a time. If you have Parallel Computing Toolbox™,
you can run multiple trials at the same time or run a single trial at a time on multiple GPUs, on a
cluster, or in the cloud. If you have MATLAB Parallel Server™, you can also offload experiments as
batch jobs in a remote cluster so that you can continue working or close your MATLAB session while
your experiment is running.

If you have Deep Learning Toolbox™ or Statistics and Machine Learning Toolbox™, you can use
Experiment Manager for your AI workflows. For more information, see Experiment Manager or
Experiment Manager.

Pivot Table Live Editor Task: Interactively summarize tabular data in


pivoted table
Use the Pivot Table task in the Live Editor to interactively perform a pivoting operation on data in a
table or timetable. You can filter the input table, specify grouping variables to designate pivoted table
rows and columns, customize the format and contents of the pivoted table, and visualize the pivoted
table in a chart. To add the task to a live script in the Live Editor, click Task on the Live Editor tab
and select the Pivot Table icon.

resize, paddata, and trimdata Functions: Change the size of data by


adding or removing elements
Change the size of array or tabular data by using the resize, paddata, and trimdata functions.
You can specify the dimensions to operate along, the fill value or pattern for padding, and the side of
the input data for resizing.

• resize adds or removes elements depending on if the length of the input data is less than or
greater than the target length. The resized data matches the target length.
• paddata only adds elements. If the length of the input data is greater than or equal to the target
length, the output data is the same as the input data.
• trimdata only removes elements. If the length of the input data is less than or equal to the target
length, the output data is the same as the input data.

1-13
R2023b

smoothdata2 Function: Smooth noisy data in two dimensions


Smooth noisy entries in two-dimensional data sets with a moving window method by using the
smoothdata2 function. You can customize the smoothing method and moving window size, specify
how missing values are handled, adjust the level of smoothing, and specify the sample points used by
the smoothing method.

kde Function: Estimate a probability function by using kernel density


estimation for univariate data
Estimate a probability function with kernel density estimation for univariate data by using the kde
function. Optionally define parameters such as the probability function to estimate, points at which to
evaluate the estimated probability function, and type of kernel smoothing function.

Join Tables Live Editor Task: Sort output timetable by row times when
row times are not key values
When the left input of the Join Tables task in the Live Editor is a timetable, you can sort the output
timetable by row times even when you do not specify row times as key values. To sort by row times in
this case, select the Sort result by row times check box. In previous releases, Join Tables does not
provide this sorting option.

This sorting option is available only when all three of these conditions are true:

• The left input is a timetable that is sorted by row times.


• You specify an outer join or an inner join.
• You do not specify row times as key values.

In all releases, the output timetable is automatically sorted by row times when you specify that row
times are key values.

Data Cleaning: Interactively fill missing data with values from nearest
neighbor rows
Fill missing entries with the mean of nearby points by using the K-nearest neighbors fill method
in the Clean Missing Data task in the Live Editor or the Clean Missing Data cleaning method in
the Data Cleaner app. Specify the number of neighbors, and define the distance between rows using
the Euclidean distance, the scaled Euclidean distance, or in the Clean Missing Data task, a custom
function.

Live Editor: Display the contents of nested tables as variables


Starting in R2023b, the output of the Live Editor displays the contents of tables or timetables that
contain nested tables or timetables as variables inline. You can interactively manipulate a nested
table, for example, by selecting or sorting a variable or copying a variable with its headers.
Previously, the output of the Live Editor displayed the dimensions of nested tables, but not the nested
table contents.

For example, use the Pivot Table task to create nested tables. The Live Editor output displays the
complete pivoted table contents.

1-14
Data Analysis

Live Editor: Copy output data as tab-delimited text


You can copy data from the output of the Live Editor as tab-delimited text. Select some data in the
output, and copy the data by pressing Ctrl+C or by right-clicking the data and selecting Copy
Selection. Then, paste the tab-delimited text. The pasted text respects the rows and columns from
the Live Editor output. For example, select and copy the elements in a row vector, and paste the
selection into a Microsoft Excel® worksheet. The first element of each worksheet column contains an
element from the copied vector.

pivot Function: Display empty groups in pivoted table


Include, rather than omit, empty groups in the pivoted table returned by the pivot function by
setting the IncludeEmptyGroups name-value argument to true. An empty group occurs when a
possible value of a variable specified by Columns or Rows is not represented in the input table, such
as in a categorical, logical, or binned numeric variable.

pivot Function: Specify row names for pivoted table as row group
names
In a pivoted table returned by the pivot function, you can now place row labels to the left of the
leftmost table variable by setting the RowLabelPlacement name-value argument to "rownames".
This option sets the RowNames property of the pivoted table to the row group names. If Rows
specifies multiple variables, the row labels are the group names concatenated with an underscore.
Previously, the pivoted table always placed row labels in the leftmost table variables.

stackedplot Function: Plot events associated with timetables


The stackedplot function can plot events as lines or shaded regions on stacked plots created from
timetables. To plot events associated with a timetable, you must attach an event table to it before you
call stackedplot. For more information on event tables, see eventtable.

To support events, stackedplot has a new EventsVisible name-value argument:

• If EventsVisible is "on", then stackedplot plots events as lines or shaded regions.


• If EventsVisible is "off", then stackedplot hides events.

1-15
R2023b

Timetable Events: Perform calculations directly on event tables


without extracting their data
You can now perform calculations directly on event tables without extracting their data. In R2023a,
you cannot perform direct calculations on event tables, though you can perform direct calculations on
tables and timetables.

For more information, see “Direct Calculations on Tables and Timetables” and “Rules for Table and
Timetable Mathematics”.

containsrange, overlapsrange, and withinrange Functions: Specify


time ranges by using event filters
You can specify a time range by using event filters when you use the containsrange,
overlapsrange, or withinrange function. To use event filters, you must first attach an event table
to the input timetable. For more information on using these functions with event filters, see
eventfilter.

Variables Editor in MATLAB Online: Interactively change display


format for datetime or duration data
In the Variables editor in MATLAB Online, you can interactively modify the display format for
datetime or duration variables. Right-click the variable or column header, select Modify Date/
Time Format, and choose from the list of display formats or specify a custom display format. The
Command Window displays the corresponding code. Previously, interactively changing the display
format for datetime data was supported only in the installed version of MATLAB. Interactively
changing the display format for duration data was not supported.

1-16
Data Analysis

Variables Editor in MATLAB Online: View and interactively edit scalar


structures, object arrays, and tables with grouped variables
The Variables editor in MATLAB Online has improved functionality for these data types:

• Scalar structure — You can now view, expand, and interactively edit the fields and nested fields in
a scalar structure. Previously, you had to open each field in another tab in the Variables editor to
view and edit its contents.

• Object array — You can now view and interactively edit the values of common properties of objects
in an object array. Previously, you had to open each object in a separate tab in the Variables editor
to view and edit its property values.

• Table with grouped variables — You can now select and interactively edit the contents of a
subcolumn in a group of table variables. Previously, interactively editing a subcolumn in a group of
table variables was not supported.

1-17
R2023b

Accessibility in MATLAB Online: Use a screen reader to interact with


the Workspace browser, Variables editor, Property Inspector, and
Import Tool
In MATLAB Online, when using a screen reader, you hear additional information about these
interactions:

• When you add variables to or remove variables from the MATLAB workspace, you hear the
number of variables added or removed.
• When you open a variable in the Variables editor, you hear the summary of the variable.
• When you edit a graphics object property using a drop-down list in the Property Inspector, you
hear the value. Previously, all Property Inspector components had screen reader support except
for drop-down list items.
• When you successfully import a variable using the Import Tool, you hear the success message
after the import is complete.

Histogram Distribution Charts: Calculate values and create


histograms using percentages
You can create histograms with percentages on the vertical axis by using the histogram and
histogram2 functions. You can normalize histogram values as percentages by using the
histcounts and histcounts2 functions. For each function, set the Normalization name-value
argument to "percentage".

tallrng Function: Specify random number algorithm without specifying


seed
When using the tallrng function, you can specify just the algorithm for the random number
generator to use. The tallrng(generator) syntax allows you to set the random number algorithm
without specifying the seed, where tallrng uses a seed of 0. This syntax is equivalent to
tallrng(0,generator). For example, tallrng("philox") initializes the Philox 4x32 generator
with a seed of 0.

Functionality being removed or changed


min and max functions will no longer support specifying second input array as character
array
Warns

1-18
Data Analysis

For the min and max functions, specifying a second input array as a character array issues a warning
and will not be supported in a future release. This change minimizes confusion with options that can
be specified as character vectors, such as the missing value condition. To maintain the previous
functionality, you can convert the second input array to double, for example,
max(A,double(B),'includenan').

1-19
R2023b

Data Import and Export

readstruct Function: Read data from JSON files


Read data from JSON files into MATLAB structure arrays using the readstruct function. For
example, S = readstruct("myFile.json") creates a structure S from myFile.json.

writestruct Function: Write structure arrays to JSON files


Write MATLAB structure arrays to JSON files using the writestruct function. For example,
writestruct(S,"myFile.json") writes the data in structure S to myFile.json.

Parquet: Create ParquetDatastore objects more efficiently with


partition control in parallel environments
In parallel environments, you can create a ParquetDatastore object more efficiently by specifying
the unit of partition and the size of partition blocks. Specify the new PartitionMethod and
Blocksize name-value arguments during creation of the datastore.

cmdsep Function: Return command separator for current platform


Return the platform-specific command separator character using the cmdsep function. You can create
a chain of commands by using cmdsep with system. For example, system("cd myfolder/" +
cmdsep + "matlab") opens a second instance of MATLAB in myfolder.

NetCDF Interface: Import netCDF data using Import Tool in MATLAB


Online and Import Data Live Editor Task
You can import netCDF data by using the Import Tool app in MATLAB Online or by using the Import
Data Live Editor task in live scripts. Using these options, you can:

• Visualize the structure and contents of netCDF data interactively.


• Search for specific variables and attributes.
• Graphically select and deselect variables and attributes to import.
• Generate reusable MATLAB code to import netCDF data.

NetCDF Interface in MATLAB Online: Import netCDF data by double-


clicking netCDF files
You can launch the Import Tool app to import netCDF data by double-clicking a netCDF file in
MATLAB Online.

Image File Format Libraries: LibTIFF library upgraded to version 4.5.0


The LibTIFF library is upgraded to version 4.5.0.

1-20
Data Import and Export

Scientific File Format Libraries: HDF4 library upgraded to version


4.2.16
The HDF4 library is upgraded to version 4.2.16.

Scientific File Format Libraries: HDF5 library upgraded to version


1.10.10
The HDF5 library is upgraded to version 1.10.10.

Scientific File Format Libraries: NetCDF library upgraded to version


4.9.1
The netCDF library is upgraded to version 4.9.1.

serialbreak Function: Send break to device connected to serial port


Use the serialbreak function with a serialport object to send a serial break of a specified
duration to your serial port device. For some devices, you can use the break signal as a way to clear
the hardware buffer.

Functionality being removed or changed


fileparts function output has same data type as input for all data types
Behavior change

Starting in R2023b, when you use the fileparts function to get the parts of a filename, fileparts
returns values of the same data type as the input, including scalar cell array inputs. Previously, a
scalar cell array input produced character array outputs.

In the netCDF interface, use compression and shuffle filter only with fixed-length data
types
Behavior change

Compression and the shuffle filter can be used only with fixed-length data types and generate an
error if applied to variables of type NC_STRING or NC_VLEN. Previously, if you specified compression
or the shuffle filter for NC_STRING or NC_VLEN variables, the specification had no effect.

In the netCDF interface, compression level of zero disables deflate filter


Behavior change

Setting the compression level to zero disables the deflate filter. Previously, the deflate filter could be
enabled with a compression level of zero.

This table shows two examples of this behavior change.

1-21
R2023b

Example Result in R2023a and Result Starting in


Earlier R2023b
Set the compression level to zero using The deflate filter is The deflate filter is
netcdf.defVarDeflate. enabled. disabled.

ncid = netcdf.create("myFile.nc","NETCDF4");ans = ans =


latdimid = netcdf.defDim(ncid,"lat",1800);
varid = netcdf.defVar(ncid,"earthgrid","double",latdimid);
1 0 0 0
netcdf.defVarDeflate(ncid,varid,true,true,0)
[~,deflate,deflateLevel] = netcdf.inqVarDeflate(ncid,varid);
netcdf.close(ncid)

[deflate deflateLevel]
Set the compression level to zero using The deflate filter is The deflate filter is
nccreate with the DeflateLevel name-value enabled and the disabled and the
argument. compression level is compression level is
zero. empty.
nccreate("myFile.nc","earthgrid",Dimensions={"lat" 1800 "col" 3600}, ...
Datatype="double",Format="netcdf4",ChunkSize=[180
ans = 360], ans
... =
DeflateLevel=0)
info = ncinfo("myFile.nc"); 0 []

info.Variables.DeflateLevel

cdfepoch function is not recommended


Still runs

There are no plans to remove cdfepoch. However, the cdfepoch function is not recommended. Use
the cdflib low-level functions instead.

cdfepoch uses datenum and datestr, which are not recommended, and is also intended for use
with cdfwrite, which is also not recommended.

todatenum function is not recommended


Still runs

There are no plans to remove todatenum. However, the todatenum function is not recommended.
Use the cdfread function instead.

The todatenum function converts cdfepoch objects to serial date numbers, which are not
recommended. Update your code to convert this type of data to datetime or double values instead.
For example, use cdfread(filename,"DatetimeType","datetime").

ConvertEpochToDatenum name-value argument of the cdfread function is not


recommended
Still runs

There are no plans to remove ConvertEpochToDatenum. However, the ConvertEpochToDatenum


name-value argument of the cdfread function is not recommended. Use the DatetimeType name-
value argument instead.

The ConvertEpochToDatenum argument converts CDF_EPOCH data to serial date numbers, which
are not recommended. Update your code to convert this type of data to datetime or double values
instead. For example, use cdfread(filename,"DatetimeType","datetime").

1-22
Mathematics

Mathematics

Ordinary Differential Equations: Use object-oriented solution


framework for ODEs
Solve ODE problems by using several new objects and methods:

• Use ode objects to define aspects of the ODE problem (such as initial time, initial value,
equations, parameters, and so on) and set basic options (such as error tolerances). Use a specific
solver by setting the value of ode.Solver explicitly, or allow the ode object to automatically
select a solver based on properties of the problem by setting the value to "auto", "stiff", or
"nonstiff".

• Common options are conveniently specified as properties of the ode object.


• Less common options can be set in the ode.SolverOptions property. Separate objects of the
form matlab.ode.options.* capture options specific to the selected solver, which simplifies
the process of finding and setting relevant options.
• Use the solve method to return the solution of the ODE problem at a discrete set of points,
either points of your choosing or points based on solver steps.
• Use the solutionFcn method to return the solution as a function that you can evaluate
anywhere on a specified interval.
• For problems involving a mass matrix, use odeMassMatrix objects to store information about the
mass matrix (such as state dependence or sparsity pattern).
• Use odeJacobian objects to store information about the Jacobian matrix for the problem (such as
matrix elements or sparsity pattern).
• Use odeEvent objects to define and track events that occur during the solution of the ODE
problem. The odeEvent object provides a new callback capability that simplifies solving systems
with discontinuities occurring with events.

The new objects and methods simplify many aspects of solving ODEs, and all functionality that is
available in existing ODE functions (ode45, ode23, ode15s, and so on) is also available in the
objects. There are no plans to remove the existing ODE functions.

rng Function: Change default algorithm and seed for random number
generator, and specify random number algorithm without specifying
seed
You can change the default algorithm and seed for the rng function from the MATLAB Preferences
window. On the Home tab, in the Environment section, click Preferences. Select MATLAB >
General, and then select a different option for Default algorithm and select a different value for
Default seed in the Random Number Generation preference.

To access and modify settings for the random number generator programmatically, you can access
the matlab.general.randomnumbers settings using the root SettingsGroup object returned by
the settings function. For example, show the default algorithm and seed that you have set for the
random number generator.

1-23
R2023b

s = settings;
s.matlab.general.randomnumbers.DefaultAlgorithm
s.matlab.general.randomnumbers.DefaultSeed

When you first start a MATLAB session or call rng("default"), MATLAB initializes the random
number generator using the default algorithm and seed that you have set. If you do not change these
settings, then rng uses the factory value of "twister" for the Mersenne Twister generator with
seed 0, as in previous releases.

When you perform parallel processing (requires Parallel Computing Toolbox), by default, the MATLAB
client uses the Mersenne Twister random number generator with seed 0 and the MATLAB workers
use the Threefry 4x64 generator with 20 rounds with seed 0. Changing the default generator settings
in the MATLAB Preferences window or using the matlab.general.randomnumbers settings affects
only the default behavior of the client and does not affect the default behavior of the parallel workers.

When using the rng function, you can specify just the algorithm for the random number generator to
use. The rng(generator) syntax allows you to set the random number algorithm without specifying
the seed, where rng uses a seed of 0. This syntax is equivalent to rng(0,generator). For example,
rng("philox") initializes the Philox 4x32 generator with a seed of 0.

MATLAB Support Package for Quantum Computing: Solve Quadratic


Unconstrained Binary Optimization (QUBO) problems
The MATLAB Support Package for Quantum Computing enables you to create and solve QUBO
problems. QUBO problems include a wide variety of combinatorial optimization problems, such as the
“Traveling Salesperson Problem with QUBO”, the “Capacitated Vehicle Routing Problem”, and many
others.

Create a QUBO problem using the qubo function. Solve the problem using the solve function. For
more information, see “Workflow for QUBO Problems”. For a complete guide to the QUBO
functionality, see “Quadratic Unconstrained Binary Optimization (QUBO)”.

To install the MATLAB Support Package for Quantum Computing, locate the support package in Add-
On Explorer using the instructions in Get and Manage Add-Ons.

MATLAB Support Package for Quantum Computing: Control circuit plot


appearance and behavior with QuantumCircuitChart objects
When you plot a circuit or composite gate with the plot method, you can now specify an output
argument to return a QuantumCircuitChart object. Set properties of the object to control the
appearance and behavior of the circuit plot. See QuantumCircuitChart Properties for more
information.

deconv Function: Perform least-squares deconvolution with different


convolved subsections
You can now perform least-squares deconvolution by specifying the Method name-value argument as
"least-squares" when using deconv. You can also specify different convolved subsections and the
Tikhonov regularization factor with least-squares deconvolution.

In previous releases, deconv can perform deconvolution using only a polynomial long-division
method. The new arguments allow you to perform least-squares deconvolution (Method="least-

1-24
Mathematics

squares"), which returns more stable solutions compared to the default long-division deconvolution
(Method="long-division").

When you use the least-squares method to deconvolve a signal y with respect to an impulse response
h, deconv returns the signal x that minimizes the norm of the residual signal (or remainder) r = y
- conv(x,h). That is, x is the solution that minimizes norm(r). You can also specify the Tikhonov
regularization factor alpha to return a solution x that minimizes norm(r)^2 + norm(alpha*x)^2
for ill-conditioned problems.

svdappend Function: Calculate revised singular value decompositions


Starting with an existing singular value decomposition (SVD) of some data, you can use svdappend
to revise the existing SVD after new rows or columns of data are added.

expmv Function: Calculate matrix exponential multiplied by vector


Calculate the product of a matrix exponential and a vector without explicitly forming the matrix
exponential by using the expmv function.

The expmv function is faster and more efficient than expm when computing the product of a matrix
exponential of a sparse matrix and a vector. The expmv function also uses an efficient algorithm to
compute the exponential integrators of ordinary differential equations, such as etA X 0, where t is a
time vector with a fixed time step, A is a square matrix, and X 0 is a column vector.

expm Function: Improved algorithm for single-precision matrices


The expm function has an improved algorithm for input matrices that are single precision. The new
algorithm can use fewer terms in the Padé approximation of some matrix exponentials.

scatteredInterpolant Object: Use multivalued interpolation to


interpolate multiple data sets simultaneously
The scatteredInterpolant object can now interpolate multiple data sets at the same query
points. Specify the Values property as a matrix, where the number of rows is the same as the
number is sample points and each column in Values represents the values of a different function at
the sample points. For example, if the sample points are column vectors with 10 elements, you can
specify Values as a 10-by-4 matrix to interpolate using four different sets of values.

1-25
R2023b

Graphics
piechart and donutchart Functions: Create configurable, interactive
pie and donut charts
Use the piechart and donutchart functions to create charts with more configuration options and
interactivity than pie charts had in previous releases.

Some of the improvements include:

• More options for formatting slice labels, slice placement, and colors
• Data tips that appear when you move the cursor over the slices

Plot Colors: Choose from nine color palettes


Plot multiple data series together using one of nine different color palettes to differentiate the
individual data series. You can change the palette by passing the palette's name to the colororder
function. The available names are "gem", "gem12", "glow", "glow12", "sail", "reef",
"meadow", "dye", and "earth". The "gem" palette is the default for most plots.

You can also use the orderedcolors function to get the RGB triplets for any of the palettes.

1-26
Graphics

abyss Function: Apply blue-to-black colormap to charts and images


Use the abyss function to get a blue-to-black colormap for coloring your charts. Like for all
predefined colormaps, you can optionally specify the number of colors for the abyss colormap.

Legend: Control the order of legend entries


Control the order of legend entries by setting the Direction property of the legend to "normal" or
"reverse". In most cases, the default direction is "normal".

Legends for stacked bar charts and area charts have a reverse order by default so the legend entries
match the stacking order of the chart. For more information, see “Legend order is reversed for
stacked bar charts and area charts” on page 1-37.

1-27
R2023b

xscale, yscale, and zscale Functions: Quickly change between


logarithmic and linear axes scales after plotting
View any dimension of a plot on a logarithmic or linear scale by calling the xscale, yscale, or
zscale function after plotting. To switch between the different scales, call any of these functions
with "linear" or "log" as an input argument. For example, yscale("log") changes the scale of
the y-axis to be logarithmic.

xsecondarylabel, ysecondarylabel, and zsecondarylabel Functions:


Create, delete, or modify secondary axis labels
Create, delete, or modify secondary axis labels by calling the xsecondarylabel,
ysecondarylabel, and zsecondarylabel functions. Secondary labels are text labels that appear
at the edge of the axes and provide additional information about the data. Often, they provide
information about the units or scale of the data.

For example, create a bar chart with datetime values along the x-axis and feet along the y-axis. By
default, the chart has a secondary x-axis label of "2020". Call the xsecondarylabel function with
an empty string to delete the "2020" label. Then add a secondary label of "Feet" to the y-axis.

x = datetime(2020,5,1:8);
y = 100:100:800;
bar(x,y)
xsecondarylabel("");
ysecondarylabel("Feet")

1-28
Graphics

Bar Charts: Specify bar labels as string vectors


When you create bar charts using the bar and barh functions, you can specify the bar labels as
string vectors. The bar tick labels appear in the order you specify them.

bar(["Vanilla","Chocolate","Cherry","Almond"],[1 2 3 4])

xregion and yregion Functions: Create unbounded regions and specify


multiple regions as matrix
Create unbounded filled regions by passing Inf or -Inf to the xregion and yregion functions. You
can also create multiple regions by specifying one matrix input argument as an alternative to
specifying two vectors of coordinates. For n regions, the matrix must be 2-by-n or n-by-2 and contain
the lower and upper bounds for all the regions.

1-29
R2023b

Text Objects: Control whether text labels are included in axes limits
Create text objects with the anchor point positions included in the axes limits calculation. To include
an anchor point in the calculation, set the AffectAutoLimits property of the text object to "on".

For example, create a line plot.


x = 0:0.1:10;
y = sin(x);
plot(x,y)

Create a text object outside of the current y-axis limits. Set the AffectAutoLimits property to
"on" so that the axes limits adjust to include the anchor point of the text.
text(1.1,1.1,"Peak",AffectAutoLimits="on")

1-30
Graphics

Contour Plots: Customize colors of contour labels


Set the LabelColor property of a Contour object to display labels that match the colors of the
contour lines, or specify one color for all the labels.

Colors and Line Styles: Control automatic color and line style selection
for additional chart objects
Now you can match the colors and line styles of more objects in the axes by setting the SeriesIndex
property of the objects to the same value. The SeriesIndex property is available for Text,
ConstantLine, ConstantRegion, Rectangle, Patch, and AnimatedLine objects, and lines
created by the line, streamline, and streamslice functions.

Also, the SeriesIndex property has a new option, "none", which enables you to opt out of
automatic selection for certain objects, such as reference lines.

1-31
R2023b

With the new SeriesIndex property support, lines created with the line, streamline, and
streamslice functions have a different default color. For more information, see “Default color is
different for lines created with the line function” on page 1-38 and “Default color is different for
plots created with the streamslice and streamline functions” on page 1-39.

Heatmap Charts: Control text interpreter for text labels in heatmap


charts
Create text, such as titles and axis labels, for heatmap charts with TeX markup, LaTeX markup, or no
markup by setting the Interpreter property of the chart.

1-32
Graphics

Images: Display images with datetime, duration, or categorical pixel


coordinates
You can now display images using datetime, duration, or categorical coordinate values with the
image and imagesc functions. Previously, only numeric and logical coordinate values were
supported.

For example, display an image with datetime values along the x-axis and duration values along the y-
axis.

x = datetime(2020,1,[1 10]);
y = minutes([1 10]);
C = peaks(10);
imagesc(x,y,C)

swarmchart Function: Create horizontal swarm charts


Create a horizontal swarm chart by setting the YJitter property when you call the swarmchart
function. When you specify the YJitter property without specifying the XJitter property, MATLAB
sets the XJitter property to "none", and the resulting distributions in the chart are horizontal.

1-33
R2023b

Geographic Plots: Some basemaps have improved appearance at high


zoom levels
The "streets-light", "streets-dark", "streets", and "topographic" basemaps hosted by
Esri®, which are used by geographic axes objects and other objects with a Basemap property, have an
improved visual appearance at high zoom levels. For example, this image compares a basemap at
zoom level 21 in R2023a with the same basemap and zoom level in R2023b.

The basemaps can also have different appearances at other zoom levels. For example, this image
compares a basemap at zoom level 15 in R2023a with the same basemap and zoom level in R2023b.

1-34
Graphics

For more information about changing the basemap of geographic axes, see geobasemap.

The basemaps hosted by Esri update periodically. As a result, you might see differences in your
visualizations over time.

Figure Code in MATLAB Online: Generate code from Camera tab


For a 3-D figure in MATLAB Online, when you change the camera view using the Camera tab,
MATLAB generates code for the camera motion. On the Tools tab of the figure window, click Camera
Tools to open the Camera tab. Use the controls in the Camera tab to interactively change the
camera view. Then, to view or copy the generated code, select Show Code in the File section of the
Figure tab.

Previously, MATLAB did not generate code when changing the camera view using the Camera tab.

Figure Code in MATLAB Online: Generate code from Property Inspector


For a figure in MATLAB Online, when you change the value of a graphics object property using the
Property Inspector, MATLAB generates code to set the property value. On the Format tab of the
figure window, click Inspect to open the Property Inspector. Use the controls in the inspector to set
the value of a property. Then, to view or copy the generated code, select Show Code in the File
section of the Figure tab.

MATLAB generates code only for properties that are specified as a 1-D array. Previously, MATLAB did
not generate code when setting a property value using the Property Inspector.

Functionality being removed or changed


GraphicsSmoothing and FontSmoothing properties will be removed
Still runs

The GraphicsSmoothing property of figures and the FontSmoothing property of axes, rulers,
geographic scales, and text objects will be removed in a future release. All graphics will be smooth
and all text will use antialiasing when these properties are removed.

1-35
R2023b

spinmap function will be removed


Still runs

The spinmap function will be removed in a future release. There is no replacement for this function.

Some printing and exporting workflows will no longer support UI components


Warns

These functions and menu items will no longer support printing or exporting UI components in a
future release:

• The print function


• The saveas function
• The File > Save As menu item on the figure
• The File > Export Setup menu item on the figure
• The Edit > Copy Options menu item on the figure

To export a figure containing UI components, call the exportapp function. For example, create a
simple app containing two buttons and a slider. Export the contents of the figure as a PDF file by
calling the exportapp function.
% Create figure with three UI components
f = uifigure;
button1 = uibutton(f,"Position",[150 300 100 50]);
button2 = uibutton(f,"Position",[300 300 100 50]);
slider1 = uislider(f,"Position",[150 250 250 3]);

% Export the contents of the figure


exportapp(f,"myapp.pdf")

Alternatively, call the getframe function to capture the contents of the figure. Then call the imwrite
function to save the content. This time, save the content as a JPEG file.
F = getframe(f);
imwrite(F.cdata,"myapp.jpg");

Exporting workflows will no longer support BMP, HDF, PBM, PCX, PGM, and PPM files
Warns

These functions and menu items will no longer support BMP, HDF, PBM, PCX, PGM, and PPM files in
a future release:

• The print function


• The saveas function
• The File > Save As menu item on the figure
• The File > Export Setup menu item on the figure

To export graphics using one of these formats, use the imwrite function instead. For example, create
a line plot, and capture the contents of the current figure using the getframe function. Then save
the content as a BMP file.
plot([0 3 2 4 1]);
F = getframe(gcf);
imwrite(F.cdata,"myplot.bmp");

1-36
Graphics

Some exporting workflows will no longer support PostScript (.ps) files


Warns

These functions and menu items will no longer support creating full-page PostScript® (.ps) files in a
future release:

• The print function


• The saveas function
• The File > Save As menu item on the figure
• The File > Export Setup menu item on the figure

To export graphics files, call the exportgraphics function. Specify an .eps, .pdf, or .emf file
extension, and set the ContentType name-value argument to "vector". This function captures
content that is tightly cropped around plots, and it does not create full-page output. For example,
create a plot and save the contents of the current figure as a PDF file containing vector graphics.

plot([0 3 2 4 1]);
exportgraphics(gcf,"myplot.pdf",ContentType="vector")

Alternatively, call the print function and specify an .eps, .emf, or .svg file extension. For example,
create a plot and save the contents of the current figure as an EPS file.

plot([0 3 2 4 1]);
print("myplot.eps","-depsc")

The getframe function will no longer capture the figure toolbar, menu bar, or borders
Warns

In a future release, the getframe function will no longer support capturing the figure toolbar, menu
bar, or the border around the figure using the rect argument. You will still be able to define a
subsection of the figure to capture, but the toolbar, menu bar, and borders will not be included.

As an alternative, you can use the exportapp function to capture the toolbar and menu bar, but not
the borders.

printopt will be removed


Warns

The printopt function will be removed in a future release. To configure printer defaults, use the
options provided by your operating system.

Legend order is reversed for stacked bar charts and area charts
Behavior change

The default order of legend entries for stacked (vertical) bar charts and area charts is now reversed
to match the stacking order of the chart. Previously, the legend entries were listed in the opposite
order of stacked bars and area charts.

To preserve the order of previous releases, set the Direction property of the legend to "normal".

lgd = legend;
lgd.Direction = "normal";

1-37
R2023b

Default color is different for lines created with the line function
Behavior change

Now that the SeriesIndex property is available for lines created with the line function, the lines
cycle through the same colors (and optional line styles) that most other plots do.

The default color change applies only to the lines you create when you specify the x, y, and optional z
arguments. If you create lines with a syntax that uses name-value arguments only, the plots look the
same as in previous releases.

For example, create two lines with x and y input arguments. In R2023b, the first line is blue and the
second line is red-orange. Before R2023b, both lines were blue.

line1 = line([0 1],[0 1]);


line2 = line([0 1],[1 2]);

1-38
Graphics

To preserve the behavior of previous releases, set the SeriesIndex property of the lines to 1. You
can set the property using a name-value argument when you call the line function, or you can set
the property of the Line object using dot notation later.

% Use a name-value argument


line1 = line([0 1],[0 1],SeriesIndex=1);

% Use dot notation


line2 = line([0 1],[1 2]);
line2.SeriesIndex = 1;

Default color is different for plots created with the streamslice and streamline functions
Behavior change

When you create a streamslice or streamline plot, MATLAB automatically assigns colors and line
styles the same way as for most other plots. For example, the first set of lines created with
streamslice are now a soft blue color.

[x,y] = meshgrid(-10:10);
u = 2.*x.*y;
v = y.^2 - x.^2;
slicelines = streamslice(x,y,u,v);
axis tight

1-39
R2023b

If you call either of the functions repeatedly, subsequent plots cycle through the same set of colors as
other plots do. In previous releases, the lines were bright blue.

To preserve the appearance from previous releases, use the set function to set the Color property to
[0 0 1].

set(slicelines,Color=[0 0 1])

RotateStyle property of a rotate3d object will have no effect


Behavior change in future release

The RotateStyle property of a rotate3d object will have no effect in a future release. Plot-box
outline rotation will no longer be supported, and rotation will be about the entire axes regardless of
the value of the property.

1-40
App Building

App Building

uislider Function: Create slider to specify range of values in apps and


on App Designer canvas
You can create a range slider using the uislider function by specifying the style as "range".
Alternatively, in App Designer, you can drag a Slider (Range) component from the Component
Library onto the canvas. The range slider has two thumbs that app users can use to adjust the range
of values. For example, this code creates a range slider that specifies values from 10 to 60.

fig = uifigure;
sld = uislider(fig,"range",Value=[10 60]);

uicontextmenu and uimenu Functions: Access information about


action used to open context menu
You can now more easily customize and share context menus in an app by using callback event data.
The ContextMenuOpeningFcn and MenuSelectedFcn callbacks have additional event data when
the callback is associated with a context menu on a UI component.

Event Data Property Description


ContextObject Object that the app user right-clicked to open the
context menu
InteractionInformation Information about where in the component the
app user right-clicked to open the context menu,
such as the cell of a table

For more information, see ContextMenu Properties and Menu Properties.

uispinner and uieditfield Functions: Create spinners and numeric edit


fields with placeholder text
Create a spinner or numeric edit field that has an empty value by setting the AllowEmpty property
to "on" and the Value property to []. The component appears with no default value. You can specify
placeholder text to give app users a hint about the type of content the field accepts by using the
Placeholder property.

For more information, see Spinner Properties and NumericEditField Properties.

1-41
R2023b

uilistbox and uidropdown Functions: Access index of component value


in list of items
Access the index of the value in a list box or drop-down component by using the ValueIndex
property. This property is useful when the component has information stored in both the Items and
ItemsData properties and you need to:

• Query both the current item and its associated data.


• Specify a new value using the index of the value in the list of items.

For example, use the ValueIndex property to display both the current item and its associated data.
fig = uifigure;
dd = uidropdown(fig, ...
Items=["Apple","Banana","Cherry"], ...
ItemsData=[0.5 0.2 1.3]);
idx = dd.ValueIndex;

disp(dd.Items(idx) + ": " + dd.Value)

Apple: 0.5

For more information, see ListBox Properties and DropDown Properties.

uitable Function: Query selected table data in current table display


When you create a table, use the DisplaySelection property of the table to query the cells that are
selected in the current table display. This property is useful when an app user has sorted or
rearranged columns in the table and you want to know which cells are selected based on the app
user's view of the data.

For more information, see Table Properties.

uicontextmenu Function: Context menus on trees appear when you


right-click anywhere in the tree
When you create a context menu and assign it to a Tree object, the context menu appears when you
right-click anywhere in the tree, including the area with tree nodes. You can share a single context
menu across all nodes in a tree by setting the context menu on the tree instead of each individual tree
node.

If you set a context menu on an individual TreeNode object, the tree node context menu still appears
when you right-click the node, even if the Tree object has an assigned context menu.

Compatibility Considerations
Previously, context menus on trees appeared only when you right-clicked on the portion of the tree
below the tree nodes. To retain this behavior, create a ContextMenuOpeningFcn callback that
shows the context menu only when the right-click occurs on a region without a tree node.
fig = uifigure;
cm = uicontextmenu(fig,ContextMenuOpeningFcn=@hideMenu);
m1 = uimenu(cm,Text="Menu Item");

1-42
App Building

t = uitree(fig,ContextMenu=cm);
n1 = uitreenode(t);

function hideMenu(src,event)
if isprop(event.InteractionInformation,"Node")
src.Visible = "off";
end
end

appmigration.migrateGUIDEApp Function: Migrating multiple apps


from GUIDE to App Designer updates app references
When you use the appmigration.migrateGUIDEApp function to migrate multiple apps at once
from GUIDE to App Designer, the function updates app references. For example, to migrate a main
app that opens a secondary app from GUIDE to App Designer, first download the GUIDE to App
Designer Migration Tool for MATLAB. Then, use the appmigration.migrateGUIDEApp function to
migrate the main and secondary apps using a single command. The function replaces all references to
the apps that you migrate together. Therefore, your migrated main app opens the migrated secondary
app without any manual changes to your app code.

App Designer: Interactively rearrange tabs, menus, tree nodes, and


toolbar tools
Interactively rearrange tabs, menus, tree nodes, and toolbar tools between parents by dragging the
component in the Component Browser. For example, interactively move and change the parents of
menus and menu items.

1-43
R2023b

App Designer: Write unit tests for custom UI components


You can write unit tests for custom UI components created in App Designer by using the app testing
framework. To enable the unit tests to access the underlying UI components in your custom
component, with the custom component open in App Designer, select the component node in the
Component Browser and select Give Test Cases Access in the Testing section. Then, reference
the underlying UI components in your unit tests to test the component behavior.

Running tests for custom UI components interactively using


matlab.unittest.TestCase.forInteractiveUse is not supported.

For more information, see “Write Tests for Custom UI Component”.

1-44
App Building

App Designer: View changes to HTML UI component source while


working in Design View
While designing an app that contains an HTML UI component, you can now more easily see updates
made to the HTML source. To show the most up-to-date content in Design View when the
HTMLSource property of the component is a path to an HTML source file, click Refresh Source
while pointing to the HTML UI component in the canvas.

For more information about using HTML UI components, see “Create HTML Content in Apps”.

Comparison Tool: Save app comparison results as PDF or DOCX


reports programmatically and interactively
You can now use the Comparison Tool to programmatically and interactively publish App Designer
app comparison results as PDF or DOCX reports. For more information, see visdiff.

Axes Interactions: Interpolate data tip location


For axes in apps created in App Designer or using the uifigure function, control the method for
placing data tips by using the InteractionOptions property of the axes. Create data tips at the
closest interpolated location on the plot to the cursor location by setting the
DatatipsPlacementMethod property of the InteractionOptions object to "interpolate". By
default, data tips are created at the closest data point to the cursor location.

Axes Interactions: Indicate azimuth and elevation angles


For axes in apps created in App Designer or using the uifigure function, indicate the azimuth and
elevation angles during interactive rotation by using the InteractionOptions property of the axes.
The azimuth and elevation angles define the camera line of sight and are displayed when the
RotateIndicator property of the InteractionOptions object is set to "azimuthelevation".
By default, the axes do not display the azimuth and elevation angles.

Axes Interactions: Zoom into rectangular region of 2-D view of 3-D


chart
For a 2-D view of a 3-D chart in apps created in App Designer or using the uifigure function, you
can zoom into a rectangular region. To enable region-zooming, click the Zoom In or Zoom Out button
in the axes toolbar, or set the Interactions property of the axes to the regionZoomInteraction
object.

For example, create a 3-D surface plot and set the view to the x- and z-axes. Click the Zoom In button
and then drag to select the region of interest.

f = uifigure;
a = axes(f);
surf(a,peaks);
view(a,[0 0]);

1-45
R2023b

Previously, for 3-D charts, the region-zoom interaction was supported only for the xy view.

App Testing Framework: Automatically scroll to components outside


viewable area
If you programmatically perform a gesture on a UI component that is not in the viewable area of an
app, the app testing framework automatically scrolls to the specified component before performing
the gesture. For the framework to bring the component into view, the component must be supported
by the scroll function and all its ancestors must have their Scrollable property set to "on" or
true. For example, create a scrollable figure with a state button that is outside the viewable area of
the figure, and then press the button.

fig = uifigure(Scrollable="on");
b = uibutton(fig,"state",Position=[fig.Position(3)+100 100 100 22]);

testCase = matlab.uitest.TestCase.forInteractiveUse;
testCase.press(b)

Web Apps and Standalone Applications: Data brushing supported in


graphics
Graphics created in web apps and standalone applications support data brushing. Use data brushing
in these applications just as you would in MATLAB figures.

1-46
Performance

Performance

Language and Programming: Improved performance for reading and


writing class property values
Reading and writing class property values shows improved performance. The largest gains in
performance are for accessing properties that do not use validation or get and set methods.

For example, the movingAverage method of StorageClass reads several elements from the data
property and writes to the average property.

classdef StorageClass
properties
data
average
N
end
methods
function obj = StorageClass(dataIn)
obj.data = dataIn;
obj.N = numel(dataIn);
obj.average = zeros(1, obj.N-2);
end
function obj = movingAverage(obj)
for ix = 1:(obj.N-2)
obj.average(ix) = (obj.data(ix) +...
obj.data(ix+1) + obj.data(ix+2))/3;
end
end
end
end

This code is about 17.5x faster than in the previous release.

s = StorageClass(1:1e6);
timeit(@()s.movingAverage)

The approximate execution times are:

R2023a: 0.497 s

R2023b: 0.0284 s

The code was timed on a Windows® 10, Intel® Xeon® CPU E5-1650 v3 @ 3.50 GHz test system.

dde23 Function: Improved performance integrating high-dimensional


systems
The dde23 function shows improved performance solving high-dimensional systems of DDEs over
long integration intervals. The improvement gets better as the number of coupled DDEs in the system
increases.

For example, this code solves a system of 500 coupled DDEs over the time interval [0 100]. The code
is about 24x faster than in the previous release.

1-47
R2023b

function timingdde23
rng default
N = 500;
C = rand(N);
lag = 1;
dderhs = @(t,y,ylag) -y-C*ylag;
sol = dde23(dderhs,lag,10+rand(1,N),[0 100]);
end

The approximate execution times are:

R2023a: 5.6 s

R2023b: 0.23 s

The code was timed on a Windows 10, Intel Xeon CPU W-2133 @ 3.60 GHz test system using the
timeit function.

timeit(@timingdde23)

nufftn Function: Improved performance with nonuniform sample


points or query points
The nufftn function shows improved performance when operating on either nonuniformly spaced
sample points or nonuniformly spaced query points.

For example, this code constructs a 262,144-by-3 matrix of nonuniform sample points t and
calculates the nonuniform discrete Fourier transform along each dimension of a 64-by-64-by-64 array.
The code is about 3.3x faster than in the previous release.

function timingSamplePoints
rng default
t = rand(64^3,3);
X = rand(64,64,64);
tic
Y = nufftn(X,t);
toc
end

The approximate execution times are:

R2023a: 0.40 s

R2023b: 0.12 s

The code was timed on a Windows 10, Intel Xeon CPU E5-1650 v4 @ 3.60 GHz test system by calling
the timingSamplePoints function.

As another example, this code constructs a 262,144-by-3 matrix of nonuniform query points f and
calculates the nonuniform discrete Fourier transform along each dimension of a 64-by-64-by-64 array.
The code is about 1.6x faster than in the previous release.

function timingQueryPoints
rng default
f = rand(64^3,3);
X = rand(64,64,64);

1-48
Performance

tic
Y = nufftn(X,[],f);
toc
end

The approximate execution times are:

R2023a: 0.40 s

R2023b: 0.25 s

The code was timed on a Windows 10, Intel Xeon CPU E5-1650 v4 @ 3.60 GHz test system by calling
the timingQueryPoints function.

fillmissing Function: Improved performance when filling entries with


previous or next numeric value
The fillmissing function shows improved performance when you specify the fill method as
"previous" or "next" for numeric data.

For example, this code fills the NaN values in a 1000-element numeric vector with the previous
nonmissing value. The code is about 4.5x faster than in the previous release.

function timingFillmissing
A = rand(1000);
idx = randperm(1000,50);
A(idx) = NaN;
for i = 1:20
F = fillmissing(A,"previous");
end
end

The approximate execution times are:

R2023a: 0.94 s

R2023b: 0.21 s

The code was timed on a Windows 10, Intel Xeon CPU E5-1650 v4 @ 3.60 GHz test system using the
timeit function.

timeit(@timingFillmissing)

ismember Function: Improved performance with small unsorted set


array
The ismember function and other set operations that call ismember show improved performance
when the set array is unsorted and the product of the numbers of elements in the query array and the
set array is less than 256.

For example, this code returns an array containing logical 1 (true) where the data in a 6-element
query array is found in a 25-element set array. The code is about 2.9x faster than in the previous
release.

1-49
R2023b

function timingIsmember
a = [1 2 3 4 5 6];
b = magic(5);
for i = 1:1e5
Lia = ismember(a,b);
end
end

The approximate execution times are:

R2023a: 0.70 s

R2023b: 0.24 s

The code was timed on a Windows 10, Intel Xeon CPU E5-1650 v4 @ 3.60 GHz test system using the
timeit function.

timeit(@timingIsmember)

islocalmax and islocalmin Functions: Improved performance when


finding local minima and maxima
The islocalmax and islocalmin functions show improved performance. The improvement is most
significant for data with large flat regions at the local maxima or minima, respectively.

For example, this code finds the local maxima of data that contains consecutive maxima values. The
code is about 2.8x faster than in the previous release.

function timingIslocalmax
x = repelem([0.5 0 1 0 1 0 1 0 0.5],10000);
for i = 1:3e2
TF = islocalmax(x);
end
end

The approximate execution times are:

R2023a: 0.91 s

R2023b: 0.32 s

The code was timed on a Windows 10, Intel Xeon CPU E5-1650 v4 @ 3.60 GHz test system using the
timeit function.

timeit(@timingIslocalmax)

Data Cleaner App: Improved rendering performance of Cleaning


Parameters panel
In the Data Cleaner app, the Cleaning Parameters panel renders more quickly after selecting a
cleaning method in R2023b than in R2023a. The delay before you can interact with the panel is
reduced.

1-50
Performance

For example, if one table variable is selected in the Data Cleaner app and you select the Clean
Outlier Data cleaning method, the Cleaning Parameters panel is ready about 1.14x faster in
R2023b than in the previous release.

The approximate panel rendering times are:

R2023a: 2.4 s

R2023b: 2.1 s

The panel rendering was timed on a Windows 10, Intel Xeon CPU E5-1650 v4 @ 3.60 GHz test system
by selecting the cleaning method in the Data Cleaner toolstrip and measuring the time it takes for the
Cleaning Parameters panel to be ready.

Tiled Chart Layouts: Improved performance for flow layouts with


spanned axes
Tiled chart layouts that have the "flow" tile arrangement and axes that span many tiles are more
responsive when the tile arrangement changes. The tile arrangements change under these
conditions:

• Adding new axes


• Resizing the figure
• Customizing the appearance of the axes by setting axes properties

For example, this code is about 1.4x faster than in the previous release.
function mylayout
tiledlayout("flow")
for i = 1:6
nexttile([1000,1000]);
end
end

1-51
R2023b

The approximate execution times are:

R2023a: 0.0380 s

R2023b: 0.0276 s

The code was timed on a Windows 10, Intel Xeon CPU W-2133 @ 3.60 GHz test system using the
timeit function.

timeit(@mylayout)

Plots in Apps: Improved performance when scrolling to zoom


Zooming using a multi-touch trackpad or mouse shows improved performance in plots within apps
and within figures created using the uifigure function. The two-finger scroll gesture and the
zooming action are more synchronized in R2023b than in R2023a. The improvement results in a
smoother experience when zooming.

For example, this code creates a figure with a plot of random data. On a Windows 10, Intel Xeon CPU
E5-1650 v4 @ 3.60 GHz test system, when you zoom into the plot using the two-finger scroll gesture
on a trackpad, the plot rendering is smoother and the zooming speed is more precise, especially at
slower speeds, in R2023b than in the previous release.

f = uifigure;
ax = uiaxes(f);
plot(ax,magic(10))

Plots in Apps: Improved responsiveness for scatter plot interactions in


apps
Interactions with scatter plots show improved responsiveness. To observe the improvement, the plot
must be created in an app or in a figure created with the uifigure function, and the markers must
either be points (".") or have a size less than 35. The improvement is most noticeable for plots with 1
million or more points.

For example, on a Windows 10, Intel Xeon CPU W-2133 @ 3.60 GHz test system, create a 3-D scatter
plot with 7 million points in an app window, and then drag to rotate the axes. The rotation is smoother
and responds more quickly to the drag gesture in R2023b than in the previous release.

function myscatter
f = uifigure;
ax = axes(f);
z = linspace(0,4*pi,7e6);
x = 2*cos(z) + rand(1,7e6);
y = 2*sin(z) + rand(1,7e6);
scatter3(ax,x,y,z,[],1:7e6,".")
end

These animations start with the corner of the xy-plane at (–2, –2) in the center of the frame.

1-52
Performance

R2023a R2023b
The rotation of the axes lags behind the The rotation of the axes is smoother and follows
movement of the cursor. the movement of the cursor more closely.

Plots in Apps: Constant lines and constant regions update


continuously as you pan
In apps, panning a plot containing ConstantLine or ConstantRegion objects is smoother and the
contents of the axes update immediately as you pan. Previously, panning showed blank areas when
you panned outside of the original axes limits.

For example, on a Windows 10, Intel Xeon CPU W-2133 @ 3.60 GHz test system, if you run this code
and then pan within the axes, the horizontal line and the gray vertical region update immediately as
you pan.

function myapp
fig = uifigure;
ax = axes(fig);
x = -10:0.1:10;
y = sin(x);
plot(ax,x,y);
xlim(ax,[-6 6])
yline(ax,0)
xregion(ax,-3,3)
end

1-53
R2023b

R2023a R2023b
The plot shows blank areas during the panning The plot updates immediately during the panning
interaction. interaction.

App Building: Improved performance when resizing apps with nested


containers
When a user resizes an app figure window for the first time, many apps reposition their content
significantly faster in R2023b than in R2023a. The improvement occurs when resizing an app with
one or more containers that have the AutoResizeChildren property set to "on", which is the
default value. The improvement is more noticeable for apps with nested containers, such as apps with
many tabs or tab groups.

For example, this code creates an app that contains five top-level tabs, each of which contains five
nested tabs. Each of the nested tabs contains 100 edit fields. When you run this app and resize it, the
resize operation is about 30x faster in R2023b than in the previous release.

function myApp
f = uifigure;
f.Position = [100 100 700 500];

% Create five tabs in a tab group


tg = uitabgroup(f,"Position",[1 1 700 500]);
nTabs = 5;
for kTab = 1:nTabs
tab = uitab(tg,"Title","Tab " + kTab);
createTabContent(tab);
end

function createTabContent(tab)
% Create a nested tab group containing five tabs
nestedTg = uitabgroup(tab,"Position",[10 10 650 450]);
nNestedTabs = 5;
for kNTab = 1:nNestedTabs

1-54
Performance

nestedTab = uitab(nestedTg,"Title","Nested Tab "+ kNTab);


% Add 100 edit fields to the tab
createNestedTabContent(nestedTab);
end
end

function createNestedTabContent(tab)
% Add 100 edit fields to a tab
hParent = 400;
n = 10;
w = 50;
h = 22;
for kRow = 1:n
for kCol = 1:n
uieditfield(tab,"Position",[(kCol-1)*(w+10)+10,hParent-kRow*(h+10),w,h]);
end
end
end
end

R2023a R2023b
The app takes about 60 seconds to resize. The app takes about two seconds to resize.

The resize interactions were times on a Windows 10, Intel Xeon Gold 6246R CPU @ 3.40 GHz test
system by running the myApp function and measuring the time it takes for the figure window to
resize.

App Building: Improved startup performance for apps with panels in


multiple tabs
In addition to the overall app startup performance improvement in R2023b, some apps that contain
panels in multiple tabs show an even greater startup performance improvement. The reason is that
MATLAB prioritizes creating the panel content in the visible tab over non-visible content when the
app first runs.

1-55
R2023b

For example, this code creates a tab group with five tabs, each containing a panel with 200 label
components. The code is about 1.2x faster than in the previous release.

function timingTabApp
fig = uifigure;
tg = uitabgroup(fig);
for k1 = 1:5
t = uitab(tg);
p = uipanel(t,Position=[1 1 t.Position(3) t.Position(4)], ...
Scrollable="on");
for k2 = 1:200
y = k2*20;
uilabel(p,Position=[20 y 60 20]);
end
end
end

The approximate execution times are:

R2023a: 7.2 s

R2023b: 6.1 s

The code was timed on a Windows 10, Intel Xeon CPU E5-1650 v4 @ 3.60 GHz test system by running
the timingTabApp function and measuring the time it takes for the components to appear in the UI
figure window.

If you have an app with many UI components, consider updating your app layout to take advantage of
this improvement. For more information, see “Improve App Startup Time”.

App Designer: Improved app loading and running performance


Loading existing apps in App Designer is faster in R2023b than in R2023a. When you load an App
Designer app, it takes less time for the app to appear in Design View.

For example, loading an app with about 400 UI components by selecting the app file on the App
Designer Start Page is about 1.3x faster than in the previous release.

The approximate load times are:

R2023a: 17.1 s

R2023b: 13.6 s

In addition, running an app from App Designer is also faster in R2023b.

For example, for an app with about 400 UI components, running the app by clicking the Run button
in App Designer results in the app appearing about 1.3x faster than in the previous release.

The approximate execution times are:

R2023a: 25.5 s

R2023b: 19.3 s

1-56
Performance

The actions were timed on a Windows 10, Intel Xeon CPU E5-1650 v4 @ 3.60 GHz test system by
loading and running a saved app.

App Designer: Improved performance when adding custom UI


components to an app
When you drag a custom UI component from the Component Library onto the App Designer canvas,
the UI component appears sooner in R2023b than in R2023a. This improvement is more noticeable
the first time you add a custom UI component to an app.

For example, on a Windows 10, Intel Xeon CPU E5-1650 v4 @ 3.60 GHz test system, the first time you
add a custom UI component to an app in Design View, the component appears on the canvas within
one second. In R2023a, the component takes several seconds to appear.

Property Inspector in MATLAB Online: Improved performance when


opening for the first time
The Property Inspector shows improved performance when opening for the first time in MATLAB
Online. The delay between clicking the Property Inspector icon or calling inspect and the
inspector being ready is reduced.

For example, open the Property Inspector for the first time in MATLAB Online. You can use the
Property Inspector 1.8x sooner than in the previous release.

ax = axes;
inspect(ax)

The approximate rendering times are:

R2023a: 7.5 s

R2023b: 4.1 s

The rendering of the Property Inspector was timed by running the code and measuring the time it
takes for the edit fields to appear in the Property Inspector.

Graphics in MATLAB Online: Images and 3-D plots in apps have


significant performance gains
Displaying images and 3-D plots in apps is significantly faster in MATLAB Online. You might also
experience similar improvements outside the context of an app (by calling figure instead of
uifigure).

For example, this code displays a scaled-up version of peppers.png using the image command. The
code is about 22x faster than in the previous release.

function myapp
f = uifigure;
ax = axes(f);
smallimg = imread("peppers.png");
bigimg = uint8(zeros(3065,4089,3));
bigimg(:,:,1) = uint8(interp2(double(smallimg(:,:,1)),3));

1-57
R2023b

bigimg(:,:,2) = uint8(interp2(double(smallimg(:,:,2)),3));
bigimg(:,:,3) = uint8(interp2(double(smallimg(:,:,3)),3));

tic
image(ax,bigimg)
drawnow
toc
end

The approximate execution times are:

R2023a: 138.5 s

R2023b: 6.4 s

The code was timed by calling the myapp function. Because MATLAB Online is hosted, performance is
independent of the computer hardware used to access it.

1-58
Software Development Tools

Software Development Tools

Source Control API: Interact with Git source control programmatically


You can now programmatically interact with source control.

• Clone a Git™ repository using the gitclone function.


• Create a Git repository object using the gitrepo function.
• Initialize a Git repository using the gitinit function.
• Create, delete, and switch branches using the createBranch, deleteBranch, and
switchBranch functions, respectively.
• Add files, remove files, and commit changes to a Git repository using the add, rm, and commit
functions, respectively.
• Inspect the commit history in a Git repository using the log function.
• Display the status of files in a local Git repository using the status function.
• Fetch or pull new data from remote Git repositories using the fetch or pull functions,
respectively.
• Merge Git branches and revisions into the current branch using the merge function.
• Publish your local changes to a remote Git repository using the push function.

Project API: Determine whether file belongs to a project


You can now programmatically determine whether a file or a folder belongs to a project by using the
matlab.project.isFileInProject function.

Source Control in MATLAB Online: Perform source control operations


using unified panel
In MATLAB Online, you can use the Source Control panel to see all active source control repositories,
manage modified files, and perform source control operations.

1-59
R2023b

To open the Source Control panel, use the Open more panels button ( ) in the sidebar.

Source Control in MATLAB Online: Expanded support for Git workflows


MATLAB Online now provides expanded support for Git workflows:

• Adding and managing Git submodules


• Sharing to GitHub®
• Initializing Git repositories
• Shallow cloning Git repositories

1-60
Software Development Tools

Projects in MATLAB Online: Added support for team collaboration


workflows
Projects in MATLAB Online now provide support for the following team collaboration workflows:

• Creating referenced projects from project folders


• Adding source control to existing projects
• Managing project labels and custom tasks using Project Settings
• Displaying shadowed files on project startup
• Upgrading projects using Project Upgrade

Project Examples: Identify and run tests in projects


This example shows how to use labels to identify tests in a project and how to create test suites from
project test files interactively and programmatically. For large projects under source control, the
example demonstrates how to run a subset of tests to reduce qualification runtime. For more
information, see “Identify and Run Tests in MATLAB Projects”.

Build Automation: Use built-in tasks to define common build actions


When using the build tool, you can create common tasks more quickly and conveniently by using the
classes in the matlab.buildtool.tasks package. Instead of writing code to implement tasks,
instantiate the classes in this package. Each class provides the flexibility to create a task tailored to
your build requirements. For an example, see “Create and Run Tasks Using Build Tool”.

Build Automation: Automatically open MATLAB project when running


builds
If your build file is in the root folder of a MATLAB project that is not already open, the build tool
automatically opens the project before running the build and then closes the project after the build
runs.

Build Automation: Invoke build tool from project subfolders


You can call the buildtool command from the folder containing the build file or any of its
subfolders. In previous releases, you can call buildtool only when the build file is in your current
folder.

Build Automation: Operate on file collections


The matlab.buildtool.io.FileCollection class has four new methods that enable you to
create file collections and operate on them:

• To create file collections from the paths to files and folders, use the
matlab.buildtool.io.FileCollection.fromPaths method.
• To replace substrings in the paths of a file collection, use the replace method.
• To transform the paths of a file collection, use the transform method.

1-61
R2023b

• To filter a file collection, use the select method.

For an example, see “Replace Substring in File Collection Paths”.

Build Automation: Name the inputs and outputs of tasks for


incremental builds
You can use the matlab.buildtool.TaskInputs and matlab.buildtool.TaskOutputs classes
to name and group the inputs and outputs of your tasks. The TaskInputs and TaskOutputs objects
behave like structures, where field names are task input or output names and field values are task
input or output values. Input values can be of any data type, and output values must be
matlab.buildtool.io.FileCollection arrays. For an example, see “Create Task with Named
Inputs and Outputs”.

Build Automation: Run tasks using build options


You can use build options to run tasks with the buildtool command or the run method:

• To run the subsequent tasks upon a build environment setup or task failure, use the -
continueOnFailure option of buildtool or the ContinueOnFailure name-value argument of
run.
• To specify a task to skip, use the -skip option of buildtool or the Skip name-value argument of
run.

For example, run the default tasks in your build plan as well as the tasks on which they depend, and
continue running the build if a failure occurs.
buildtool -continueOnFailure

Unit Testing Framework: Programmatically access code coverage


results using the runtests function
You can use the runtests function to programmatically access the results of code coverage analysis
for your source code. To run tests and return coverage results, specify the additional output
argument of runtests as well as the ReportCoverageFor name-value argument. When you invoke
runtests by specifying both these arguments, the function returns the coverage results as a
matlab.coverage.Result vector. For example, run your tests and return the results of code
coverage analysis for the source code in your current folder.
[testResults,coverageResults] = runtests("myTestFile.m", ...
ReportCoverageFor=pwd)

Unit Testing Framework: Test for missing elements


The matlab.unittest.constraints.HasMissing class provides a constraint to test if an array
has any missing elements. The constraint is satisfied by an array that has at least one missing
element.

Unit Testing Framework: Modify test report title


You can modify the test report title when you generate a test report using a method of the
matlab.unittest.plugins.TestReportPlugin or matlab.unittest.TestResult class. To

1-62
Software Development Tools

modify the title, specify the Title name-value argument. For example, run your tests and generate a
PDF test report with a specified title.

results = runtests("myTestFile.m");
generatePDFReport(results,Title="My Test Report")

App Testing Framework: Automatically scroll to components outside


viewable area
If you programmatically perform a gesture on a UI component that is not in the viewable area of an
app, the app testing framework automatically scrolls to the specified component before performing
the gesture. For the framework to bring the component into view, the component must be supported
by the scroll function and all its ancestors must have their Scrollable property set to "on" or
true. For example, create a scrollable figure with a state button that is outside the viewable area of
the figure, and then press the button.

fig = uifigure(Scrollable="on");
b = uibutton(fig,"state",Position=[fig.Position(3)+100 100 100 22]);

testCase = matlab.uitest.TestCase.forInteractiveUse;
testCase.press(b)

matlab.test.behavior.Missing Class: Test against constructor


arguments that result in incompatible values
You can verify whether objects of your class created with certain constructor arguments satisfy the
missing value contract in MATLAB. To test your class with a constructor argument, specify the
ExtraConstructorArguments property of the matlab.test.behavior.Missing class as that
argument. This property is useful when different constructor arguments result in incompatible
values, such as values that cannot be concatenated or compared.

Functionality being removed or changed


Build tool restores the current folder after running each task
Behavior change

To prevent a task from affecting subsequent tasks by changing the current folder, the build tool
restores the current folder after running each task. In previous releases, the build tool does not
restore the current folder after running each task.

files converts relative paths to absolute paths


Behavior change

If you create file collections with the files method, the paths of the file collections are absolute
paths. Previously, the method did not convert any relative paths that you specified to absolute paths.
To create file collections with relative paths, use the
matlab.buildtool.io.FileCollection.fromPaths method, or use a string vector to specify an
argument or property that requires file collections.

1-63
R2023b

External Language Interfaces

Call MATLAB from C++: Generate output types for strongly typed
methods and functions
The matlab.engine.typedinterface.generateCPP function generates output types for
functions and methods in the strongly typed C++ interface. For more information, see “Output
Argument Validation”. For an example, see “Write MATLAB Code for Strongly Typed C++ Interface”.

Publish C++ Interface: Support for pointer return of string and


fundamental types
When publishing a MATLAB interface to a C++ library function, you can define pointer return
arguments for non-const string and fundamental types. You also can specify a deleter function for
both const and non-const string and fundamental pointer return types. MATLAB uses the deleter
function to manage the life cycle of the memory represented by the argument.

For examples, see “Define Output Pointer Argument”.

Call MATLAB from .NET: Generate C# code interface for MATLAB


packages, classes, and functions
The matlab.engine.typedinterface.generateCSharp function creates C# .cs files from
MATLAB packages, classes, and functions. For more information, see “Strongly Typed Interface for
C#”.

Call .NET from MATLAB: Create explicit interface view of .NET object
You can create an explicit view of a .NET object as one of its implemented interfaces using the
NET.interfaceView function. Interfaces can define methods or properties that are not accessible
from the .NET object directly.

Python: Support for version 3.11


MATLAB now supports CPython version 3.11, in addition to existing support for versions 3.9 and
3.10. For supported version information, see Versions of Python Compatible with MATLAB Products
by Release.

Python Interface: Use of environment variable PYTHONHOME to load


interpreter
MATLAB accesses these settings when loading the Python® interpreter:

• User settings for the Python environment, configured using the pyenv function. If the version you
specify conflicts with the version specified by PYTHONHOME, then delete the environment variable
before calling pyenv. The value set by pyenv is persistent across MATLAB sessions. For more
information, see “Set Python Version on Windows Platform” or “Set Python Version on Mac and
Linux Platforms”.

1-64
External Language Interfaces

• PYTHONHOME environment variable, specifies where to find the standard Python libraries. To view
the value of the variable in MATLAB, type getenv("PYTHONHOME"). For more information, see
“Use PYTHONHOME Environment Variable”.
• System PATH environment variable. To view the system path in MATLAB, type getenv("PATH").
• Windows registry.

Python Interface: Convert list and tuple of Python datetime or


timedelta objects to MATLAB arrays
If a Python function returns multiple datetime objects as a list or a tuple of Python datetime
objects, use the MATLAB datetime function to convert the list or tuple to a MATLAB datetime
array. For more information, see “Handle Multiple Python datetime Objects Returned from Python
Function”.

If a Python function returns multiple timedelta objects as a list or a tuple of Python timedelta
objects, use the MATLAB duration function to convert the list or tuple to a MATLAB duration
array. For more information, see “Handle Multiple Python timedelta Objects Returned from Python
Function”.

Python Interface: Resolve Python configuration issues


Error messages provide additional help for you to resolve these Python configuration issues:

• Unable to find a supported Python version. See Versions of Python Compatible with MATLAB
Products by Release.
• Python installed from the Microsoft Store is not supported. See “Configure Your System to Use
Python”.
• Python shared library not found on UNIX® platforms. See “Set Python Version on Mac and Linux
Platforms”.

Compilers: Download MinGW-w64 8.1 from Add-On Explorer


As of R2023b, you can download MinGW®-w64 8.1 from the Add-On Explorer.

To download or configure other supported versions of MinGW, see MATLAB Support for MinGW-w64
C/C++ Compiler. For an up-to-date list of supported compilers, see Supported and Compatible
Compilers.

Compilers: Support for NAG Fortran on Apple silicon


MATLAB supports the NAG® Fortran compiler on Apple silicon platforms. For an up-to-date list of
supported compilers, see Supported and Compatible Compilers.

Compilers: Support for Microsoft Visual Studio Build Tools


MATLAB supports Build Tools for Visual Studio® 2022 and 2019 for building C and C++ interfaces,
MEX files, and standalone MATLAB engine and MAT-file applications on Windows platforms. For an
up-to-date list of supported compilers, see Supported and Compatible Compilers.

1-65
R2023b

Functionality being removed or changed


Python: Version 3.8 is no longer supported
Errors

Support for Python version 3.8 is discontinued. For continued support for your applications, upgrade
to a supported version of Python. For supported version information, see Versions of Python
Compatible with MATLAB Products by Release.

Perl: MATLAB support for version 5.38.0 on Windows


Behavior change

As of R2023b, MATLAB on Windows ships with an updated version of Perl, version 5.38.0, and
supports an updated version of HTML::Parser, version 3.81.

If you use the perl command on Windows platforms, see https://www.perl.org/ for information
about using this version of the Perl programming language. For a standard distribution of
HTML::Parser, source code, and information about using HTML::Parser, see https://
metacpan.org/pod/HTML::Parser.

1-66
Hardware Support

Hardware Support

Support for ArduCam Multi Camera Adapter Module on Raspberry Pi


Hardware
Starting in R2023b, you can use the new arducam object to set up a connection between MATLAB
and ArduCam Multi Camera Adapter Module V2.2. You can sequentially acquire images from up to
four cameras attached to the ArduCam Multi Camera Adapter Module V2.2. MATLAB Support
Package for Raspberry Pi® Hardware supports 5MP OV5647 cameras, which are compatible with
ArduCam Multi Camera Adapter Module V2.2.

1-67
2

R2023a

Version: 9.14

New Features

Bug Fixes

Compatibility Considerations
R2023a

Environment

MATLAB Install: Reduce footprint using default installation without


local documentation
Starting in R2023a, the documentation is not installed as part of a MATLAB or other product
installation. This change significantly reduces the installation footprint of products. In most cases, not
installing the documentation has no effect on the availability of documentation, as the Help Center
displays the web documentation by default.

Compatibility Considerations
The documentation is not installed as part of a product installation. If you run MATLAB on a system
with no internet connection (permanently offline), or if you plan to work offline occasionally on an
otherwise internet-connected machine, you can install the documentation on your computer after
installing products. For more information, see Install Documentation.

Editor: Interactively increment numeric values within section and run


section after every change
You can increment, decrement, multiply, or divide numeric values in the Editor and then run the
current section after every change. This workflow can help you fine-tune and experiment with your
code.

To adjust a numeric value, select the value or place your cursor next to the value. Next, right-click
and select Increment Value and Run Section. In the dialog box that appears, specify a step value
for addition and subtraction or a scale value for multiplication and division. Then, click one of the
operator buttons to add to, subtract from, multiply, or divide the selected value in your section.
MATLAB runs the section after every click.

Live Editor Controls: Add file browser to select file interactively in live
script
You can add a file browser to your live script to interactively select a file by opening a file selection
dialog box. To add a file browser, go to the Live Editor tab, and in the Code section, click
Control. Then, select File Browser.

For more information, see Add Interactive Controls to a Live Script.

2-2
Environment

Live Editor Controls: Align controls within a section when code is


hidden
The Live Editor automatically left-aligns drop-down lists, edit fields, numeric sliders, and numeric
spinners within a block of code when the code is hidden.

For example, this live script contains three controls in two different blocks of code . When the code is
visible, the controls appear inline with the code.

When the code is hidden, the Live Editor automatically aligns the second and third controls, as they
are in the same block of code. The first control is not in the same block of code and is therefore not
aligned to the other two controls.

The Live Editor does not align check boxes, buttons, and file browsers.

Desktop Layout in MATLAB Online: Access desktop tools and change


the desktop layout using sidebars
The MATLAB Online desktop includes sidebars on either side of the desktop to access desktop tools
and change the desktop layout. The sidebars show the tools, such as the Workspace panel and the
Files panel, that are docked on either side of the desktop. If there are no tools docked on one side,
the sidebar for that side is hidden. You can use the sidebars to show and hide tools, group them
together, and move them from one location to another.

When a tool is docked on the left or right side of the desktop, the sidebar on that side displays an icon
for the tool. To show or hide the tool, click its icon in the sidebar. To show and hide multiple tools
together, group them by dragging one of the tool icons next to another tool icon. To move a tool to a
different location on the desktop, drag the tool or the icon for the tool to the new location. If there are
no tools docked on one side, then the sidebar on that side is hidden.

2-3
R2023a

Code Issues Tool in MATLAB Online: Check code for errors and
warnings using Code Issues tool
You can use the Code Issues tool to view error and warning messages about your code. The Code
Issues tool displays the coding problems found by the MATLAB Code Analyzer as it automatically
checks your code. Using the Code Issues tool, you can choose to view the errors and warnings for the
current file or for all open files. You also can filter the list of messages by type (error or warning) as
well as by message text.

To open the Code Issues tool, go to the Editor or Live Editor tab, and in the Analyze section, click
Code Issues. By default, the Code Issues tool opens on the right side of the desktop. To hide the

Code Issues tool, click the Code Issues icon in the sidebar.

2-4
Environment

Find Files Tool in MATLAB Online: Search for files with improved Find
Files tool
You can use the improved Find Files tool to search for files based on name or content. When
searching, you can choose whether to match the case of your search text as well as whether to match
the whole word. You also can select what folder to search in and filter results by file extension. To

search for files, click the Find Files icon in the sidebar on the left side of the MATLAB Online
desktop.

2-5
R2023a

Editor in MATLAB Online: Edit read-only files


You can now edit read-only files in MATLAB Online. When you save the file, MATLAB prompts you to
overwrite the file or save the file using a different name.

Search in MATLAB Online: Access videos using Search box


In MATLAB Online, you can now use the Search box in the upper-right corner of the desktop to easily
access videos that show you how to use MathWorks® products. In addition to videos, the Search box
results include toolstrip actions, preferences, and Help Center resources such as functions, blocks,
examples, and answers. To navigate to the Search box using a keyboard, press Ctrl+Shift+Space (or
Command+Shift+Space on macOS systems).

System Command Functions: Set and get multiple variables using


operating system commands
Set and get multiple environment variables using the setenv, unsetenv, getenv, and isenv
functions with string arrays and cell arrays of character vectors as input.

loadenv Function: Load environment variables from .env and plain


text files
You can load environment variables from a .env or other plain text file by using the loadenv
function. By using a .env file you can separate sensitive configuration data from code and provide
different sets of configurations for different workflows.

Comparison Tool: Save text comparison results as PDF or DOCX


reports programmatically and interactively
You can now use the Comparison Tool to programmatically and interactively publish text comparison
results as PDF or DOCX reports. For more details, see Compare Text Files and visdiff.

2-6
Environment

Toolbox Packaging: Specify packaging options when creating custom


toolbox programmatically
When creating a custom toolbox programmatically using the
matlab.addons.toolbox.packageToolbox function, you can specify packaging options using a
ToolboxOptions object. Using the ToolboxOptions object, you can specify information about the
toolbox including what platforms the toolbox supports and what MATLAB releases the toolbox is
compatible with. You also can specify what files to package and what additional software to install
with the toolbox. For an example, see Specify packaging options using ToolboxOptions object.

Functionality being removed or changed


XML comparison type for visdiff function will be removed
Still runs

The XML comparison type for the visdiff function will be removed in a future release. Overriding
the default comparison type by specifying "xml" will not be supported in a future release. In R2023a,
scripts that use visdiff(filename1,filename2,"xml") continue to work.

lookfor function searches help text in third-party and user-authored MATLAB program files
Behavior change

The lookfor function searches help text in third-party and user-authored MATLAB program files. In
R2022b, lookfor does not search help text in third-party and user-authored MATLAB program files.

2-7
R2023a

Language and Programming


Code Analyzer: Enable custom checks and configure existing checks
You can configure existing checks displayed in the MATLAB editor by the Code Analyzer and add
custom checks by placing a file named codeAnalyzerConfiguration.json in a resources folder.
The configuration file is effective in the folder containing the resources folder and any subfolders.

You can modify existing Code Analyzer checks, including whether the check is enabled and its
severity, message text, and parameters if the check has any, such as to limit the number of input and
output arguments for a function. You can also create custom checks that trigger when specific
functions are used. For more information on configuring Code Analyzer checks, see Configure Code
Analyzer.

Validate your codeAnalyzerConfiguration.json configuration file for proper formatting by using


matlab.codeanalysis.validateConfiguration.

fix Function: Fix code issues from the command line


Fix certain code issues directly from the command line using the fix function on codeIssues objects.

For example, create a script file with the following code:


x = [1 2 3]
for n = 1:3
y(n) = x
end

Run codeIssues on the file to identify code issues.


issues = codeIssues("exampleScript")

issues =

codeIssues with properties:

Date: 03-Nov-2022 10:46:40


Release: "R2023a"
Files: "C:\MyCode\exampleScript.m"
CodeAnalyzerConfiguration: "active"
Issues: [3×10 table]
SuppressedIssues: [0×11 table]

Issues table preview

Location Severity Fixability


_________________ ________ __________ ______________________________________________

"exampleScript.m" info auto "Add a semicolon after the statement to hide t


"exampleScript.m" info manual "Variable appears to change size on every loop
"exampleScript.m" info auto "Add a semicolon after the statement to hide t

Note that if the value for Fixability is auto then the issue can be fixed using fix. Issues with
manual will not be fixed. Use fix to apply the recommended fix to the issue identified.

2-8
Language and Programming

fix(issues,"NOPTS")

ans =

codeIssues with properties:

Date: 03-Nov-2022 10:47:04


Release: "R2023a"
Files: "C:\MyCode\exampleScript.m"
CodeAnalyzerConfiguration: "active"
Issues: [1×10 table]
SuppressedIssues: [0×11 table]

Issues table preview

Location Severity Fixability


_________________ ________ __________ ______________________________________________

"exampleScript.m" info manual "Variable appears to change size on every loop

Code Analyzer App: Apply fixes to code issues interactively


Fix certain code issues directly from the Code Analyzer app using the Fix button.

dictionary Object: Access and assign dictionary cell values with curly
braces
Data in cells can be looked up and assigned directly using curly braces, {}. When dictionary values
are cells, a lookup using parentheses, (), returns a cell. Accessing the contents of that cell requires
indexing into the cell. This feature allows contents of cell values to be accessed directly. For example,
the dictionary d has three cell values.

2-9
R2023a

d =

dictionary (double ⟼ cell) with 3 entries:

1 ⟼ {["Hello"]}
2 ⟼ {[4 5 6]}
3 ⟼ {@sin}

Perform a lookup using parentheses. The lookup returns the value as a cell containing an array.
d(2)

ans =

1×1 cell array

{[4 5 6]}

Perform a lookup using curly braces. The lookup returns the value as an array.
d{2}

ans =
[4 5 6]

Output Argument Validation: Debug within output argument blocks


You can now use the MATLAB debugger within output arguments blocks of functions. While
debugging an arguments block, the workspace is read-only. For more information on using the
debugger, see Debug MATLAB Code Files.

Functionality being removed or changed


Warning about indexing with no subscripts (MATLAB:subscripting:noSubscriptsSpecified)
has been removed

The warning about indexing into a built-in type with no subscripts


(MATLAB:subscripting:noSubscriptsSpecified) has been removed. In previous releases, the
warning was off by default, but when users opted in, the warning would appear when indexing with
no subscripts.
warning("on","MATLAB:subscripting:noSubscriptsSpecified");
x = [1 2 3 4 5];
y = x()

Warning: A value of class "double" was indexed with no subscripts


specified. Currently the result of this operation is the indexed value
itself, but in a future release, it will be an error.

y =

1 2 3 4 5

Starting in R2023a, the behavior of indexing with no subscripts remains the same and does not error,
but the warning no longer appears. Using the warning command to turn the warning on or off has no
effect.

2-10
Language and Programming

Defining classes and packages: Using schema.m will not be supported in a future release
Still runs

Support for classes and packages defined using schema.m files will be removed in a future release.
Replace existing schema-based classes with classes defined using the classdef keyword.

2-11
R2023a

Data Analysis

pivot Function: Summarize tabular data using pivot table


Perform a pivoting operation on data in a table or timetable by using the pivot function. Specify
grouping variables that define variables or rows in the pivoted table using colvars or rowvars.

Optionally define parameters such as the data variable, function to apply to the data variable, and
grouping variable binning schemes by specifying name-value arguments.

table and timetable Data Types: Perform calculations directly on


tables and timetables without extracting their data
You can now perform calculations directly on tables and timetables without extracting their data. All
the variables in your tables and timetables must have data types that support calculations. You can
also perform operations where one operand is a table or timetable and the other is a numeric or
logical array. Previously, all calculations required you to extract data from your tables and timetables
by indexing into them.

For more information, see Direct Calculations on Tables and Timetables and Rules for Table and
Timetable Mathematics.

Timetable Events: Find and label events in timetables using attached


event tables
To find and label events in a timetable, attach an event table to it. An event table is a timetable of
events. An event consists of an event time (when something happened), often an event length or
event end time (how long it happened), often an event label (what happened), and sometimes
additional information about the event. Event tables are designed to be attached to timetables. When
you attach an event table to a timetable, you can find or label rows in the timetable that occur during
events.

MATLAB provides these functions to create event tables from input data, filter timetable rows on
event times, and synchronize events to timetables:

• eventtable
• extractevents
• eventfilter
• syncevents

combinations Function: Generate all element combinations of arrays


Generate all element combinations of arrays of varying sizes and data types by using the
combinations function. Each row of the output table is a combination. Applying the combinations
function is equivalent to finding the Cartesian product of sets of elements.

2-12
Data Analysis

fillmissing2 Function: Fill missing entries in two-dimensional data


Fill missing entries in two-dimensional data sets using the fillmissing2 function. You can fill
missing entries using interpolation or moving window methods.

fillmissing Function: Use values from nearest neighbors to fill missing


data
You can use the 'knn' method of the fillmissing function to fill missing entries in your data with
the corresponding values in the nearest row, based on the pairwise Euclidean distance between rows.
You can optionally specify a value k for the 'knn' method to fill missing entries with the mean of the
corresponding values in the k nearest rows.

You can also specify a distance function, using the Distance name-value argument, to measure the
distance between rows with a specified metric. Distance can have any of these values:

• 'euclidean' — Euclidean distance (default)


• 'seuclidean' — Scaled Euclidean distance
• A function handle — User-specified distance function

Descriptive Statistics and Arithmetic: Omit or include missing data of


multiple data types
When analyzing and preprocessing data, you can optionally specify to omit or include numeric,
datetime, duration, and categorical missing data. Use the "omitmissing" or "includemissing"
flags in addition to any previously supported missing condition flags for these functions:

• Basic statistics — min, max, bounds, median, mean, std, var, rms
• Basic arithmetic — sum, prod
• Forecasting metrics — rmse, mape
• Covariance — cov
• Cumulative statistics — cummax, cummin, cumsum, cumprod
• Moving statistics — movmin, movmax, movmean, movmedian, movmad, movstd, movvar, movsum,
movprod
• Data preprocessing — smoothdata, detrend

Find and Remove Trends Live Editor Task: Interactively find and
remove periodic and polynomial trends
The Find and Remove Trends task in the Live Editor can now identify periodic trends for regularly
spaced input data. Select the Periodic trend type, and choose the SSA or STL algorithm.

The task can also return polynomial and periodic trends, in addition to the detrended data. Specify
Output as Trends.

Previously, this task identified only polynomial trends and returned only the detrended data.

2-13
R2023a

Compatibility Considerations
To reflect the enhanced functionality of finding and removing periodic and polynomial trends, this
task in the Live Editor is now named Find and Remove Trends. Previously, this task was named
Remove Trends.

Data Cleaner App: Save session as MAT-file and reload session


When working in the Data Cleaner app, save the session as a binary MAT-file containing the data and
cleaning steps. To save the session file, in the File section of the Home tab, click Save. To reload the
session, in the File section of the Home tab, click Open.

head and tail Functions: Get top or bottom rows of array


Display or return the top rows of a vector, matrix, multidimensional array, or cell array using the
head function, or the bottom rows using the tail function. Previously, head and tail supported
only table, timetable, and tall array input data.

groupsummary Function: Compute number of unique elements


Compute the number of distinct nonmissing elements in each group of data. Specify the
"numunique" or "all" method of the groupsummary function, or select the Number of unique
values or Select all computation method in the Compute by Group task in the Live Editor.

Compatibility Considerations
The "all" computation method now returns the number of unique values in addition to the
computation methods in the previous release.

movevars Function: Move table variables after last variable without


After name-value argument
When using the movevars function, you can now move variables after the last variable without
specifying the After name-value argument.

For example, create a table. Then move the first variable after the last variable.

T = table([1;3;5],[2;4;6],[3;6;9])

T =
3×3 table
Var1 Var2 Var3
____ ____ ____
1 2 3
3 4 6
5 6 9

T = movevars(T,"Var1")

T =
3×3 table
Var2 Var3 Var1

2-14
Data Analysis

____ ____ ____


2 3 1
4 6 3
6 9 5

Compatibility Considerations
In previous releases, calling movevars without specifying either the After or Before name-value
argument resulted in an error. Moving a variable after the last variable required one of these two
syntaxes.

T = movevars(T,"Var1","After",width(T))
% or
T = movevars(T,"Var1","After","Var3")

rowfun and varfun Functions: OutputFormat name-value argument


can take "auto" as value
The OutputFormat name-value argument can take "auto" as a value. This value is the default
value. It causes the rowfun and varfun functions to return outputs whose data types match the data
types of their inputs.

day Function: Return ISO day of week


To return the ISO day of week number, use the "iso-dayofweek" option with the day function. In
the ISO 8601 standard, Monday is day 1 of the week.

For example, return the ISO day of week number for today.

D = datetime("today");
dayNumber = day(D,"iso-dayofweek")

week Function: Return ISO week of year or week of month


To return the ISO week of year number, use the "iso-weekofyear" option with the week function.
In the ISO 8601 standard, a week begins on Monday. Week 1 of a year is defined as the first week in
the year with at least four days.

To return the week of month number, use the "iso-weekofmonth" option with the week function. A
week begins on Monday. Week 1 of a month is defined as the first week in the month with at least four
days. ISO 8601 does not specifically define the week of month number. However, this option returns a
week of month number that is consistent with the ISO week of year number.

For example, return the ISO week of year and week of month numbers for today.

D = datetime("today");
weekOfYear = week(D,"iso-weekofyear")
weekOfMonth = week(D,"iso-weekofmonth")

2-15
R2023a

Variables Editor: Edit categories of categorical table variable in


MATLAB Online
In the MATLAB Online Variables editor, you can create, remove, or merge categories in a categorical
table or timetable variable. To edit the categories, pause on the header of a categorical variable and
click the triangle icon, or right-click the variable, and select Edit Categories.

2-16
Data Import and Export

Data Import and Export

Import Data Live Editor Task: Import data in live scripts


The Import Data Live Editor task allows you to import various types of data in a live script within a
single framework. You can import these types of data:

• MAT-file (for example, .mat)


• Text (for example, .csv)
• Spreadsheet (for example, .xlsx)
• Image (for example, .png)
• Audio (for example, .wav)
• Video (for example, .avi)

To add the task to a live script in the Live Editor, click Task on the Live Editor tab and select the
Import Data icon.

audiowrite Function: Write MP3 audio files


You can write MP3 audio files using the audiowrite function.

imfinfo Function: Get information about XMP metadata embedded in


JPEG files
The imfinfo function returns Extensible Metadata Platform (XMP) metadata embedded in JPEG files
in the 'XMPData' field of the output structure. The function also returns International Press
Telecommunications Council (IPTC) metadata embedded in the XMP namespace. The IPTC data is
stored in the 'Iptc4xmpCore' (core metadata) and 'Iptc4xmpExt' (extension metadata) subfields
of 'XMPData'.

Parallel Processing: Use readtable in thread-based environments


You can use the readtable function in thread-based environments. Parallel processing results in
improved performance when reading data, especially with remote data.

Scientific File Format Libraries: CDF library upgraded to version 3.8.1


The CDF library is upgraded to version 3.8.1.

Scientific File Format Libraries: CFITSIO library upgraded to version


4.1.0
The CFITSIO library is upgraded to version 4.1.0.

2-17
R2023a

Functionality being removed or changed


web function will return handle to most recent MATLAB web browser as MATLAB class
Behavior change in future release

In a future release, the web function will return a handle to the most recent MATLAB web browser as
a MATLAB class. Currently, the web function returns the handle as a Java class. With this change,
some methods that were previously supported in the returned handle will no longer be supported.

In most cases, you will not need to make any changes to your code. However, if you are using
methods that are not supported in the returned MATLAB class, you will need to update your code.

2-18
Mathematics

Mathematics

MATLAB Support Package for Quantum Computing: Build, simulate,


and run quantum algorithms
The MATLAB Support Package for Quantum Computing enables you to:

• Build circuits to implement quantum algorithms using a variety of built-in gate functions.

• quantumCircuit
• quantum.gate.SimpleGate
• For a complete list of built-in gate functions, see Types of Quantum Gates.
• Leverage composite gates to create custom gates from available built-in gates, capture complex
operations, and organize circuits.

• quantum.gate.CompositeGate
• Verify implementation of quantum algorithms with simulations on your local computer. Analyze
simulation results to determine the outcome of a measurement.

• simulate
• quantum.gate.QuantumState
• Run gate-based quantum algorithms by connecting to quantum hardware on Amazon® Web
Services (AWS®).

• run
• quantum.backend.QuantumDeviceAWS
• quantum.backend.QuantumTaskAWS
• quantum.gate.QuantumMeasurement

See Quantum Computing and Introduction to Quantum Computing for more information.

To install the MATLAB Support Package for Quantum Computing, locate the support package in Add-
On Explorer using the instructions in Get and Manage Add-Ons.

pageeig Function: Perform eigenvalue decomposition on pages of N-D


arrays
Use the pageeig function to calculate eigenvalues and eigenvectors of the pages of N-D arrays. In
this context, the N-D array is treated as a container for several 2-D matrices.

randi Function: Create random logical array


Use randi to create a random logical array by specifying the typename argument as "logical" or
the prototype p as a logical array.

For example, you can create a 5-by-5 random logical array using randi([0 1],5,"logical").

2-19
R2023a

Functionality being removed or changed


spy plots have adjusted default behavior for aspect ratio and marker size
Behavior change

The aspect ratio of spy plots has a 1-to-10 limit, after which the plot stops adjusting to the matrix
shape. You can use pbaspect("auto") for no special aspect ratio or pbaspect([size(A,2)
size(A,1) 1]) for the previous behavior of a matching aspect ratio, even for very "squeezed"
cases.

Additionally, the default marker size is based only on the matrix size. Previously, the point size of the
axes on creation could also affect the marker size.

2-20
Graphics

Graphics

xregion and yregion Functions: Highlight horizontal or vertical regions


of plots
Highlight one or more horizontal or vertical regions of a plot with the xregion and yregion
functions. You can set properties to customize the color and boundary lines of these shaded regions.

sky Function: Apply monochromatic colormap to charts


Use the sky function to color charts with the same monochromatic colormap that heatmap charts
use. Like for all predefined colormaps, you can optionally specify the number of colors for the sky
colormap.

2-21
R2023a

tiledlayout Function: Create horizontal or vertical layouts


Create horizontal or vertical layouts by specifying "horizontal" or "vertical" as the first input
argument to the tiledlayout function. For example, create a horizontal layout and add three plots.

tiledlayout("horizontal")
x = 1:5;
nexttile
plot(x)
nexttile
bar(x);
nexttile
contourf(peaks)

animatedline Function: Create animated lines using numeric,


datetime, or duration data
Use the animatedline function to create animated lines using single, double, integer, datetime, or
duration data for the x-, y-, and z-coordinates.

Grid Lines: Customize grid line thickness


Change the thickness of grid lines independently of the box outline and tick marks by setting the
GridLineWidth and MinorGridLineWidth properties of the axes. Before R2023a, the LineWidth
property of the axes was the only property for controlling the grid line width. However, that property
controlled the grid lines, box outline, and tick marks together. Now you can control the thickness of
the grid lines separately.

2-22
Graphics

Axes Labels: Rotate x- and y-axes labels without overlapping the axes
When you change the Rotation property of an axis label in a 2-D plot, the HorizontalAlignment
and VerticalAlignment properties of the label automatically change to prevent overlap between
the label and the axes.

For example, create a plot with a y-axis label.

plot([0 3 1 6 4 10])
ylab = ylabel("Y Data");

Rotate the label so that the text is horizontal. MATLAB automatically adjusts the
HorizontalAlignment and VerticalAlignment properties to prevent the overlap.

ylab.Rotation = 0;

2-23
R2023a

Plotting Series of Lines: Control cycling order of line styles


When plotting a series of multiple lines, you can use the LineStyleCyclingMethod property of the
axes to control how different lines are distinguished from one another. Specify this property as one of
these values:

• "withcolor" — Cycle through the line styles with the colors


• "beforecolor" — Cycle through the line styles before cycling through the colors
• "aftercolor" — Cycle through the line styles after cycling through the colors (default)

Plotting Series of Lines: Control whether the data range of a line


affects automatic axes limits
Specify whether a specific line affects the automatically selected axes limits by setting the
AffectAutoLimits property. By default, the axes limits change to encompass the data range for
each successive line you create. Setting this property enables you to focus on the range of a subset of
lines in the axes.

2-24
Graphics

fontsize and fontname Functions: Optionally specify the object


containing the text
When calling the fontsize or fontname functions, you can omit the object argument when you
want the functions to affect the current figure.

DatetimeRuler Object: Set or get the reference date for plotting


datetime values
Set the ReferenceDate property of a DatetimeRuler object when you plot datetime values. This
property is useful for synchronizing tick placement across different axes and for plotting data from
different time zones together.

Image Display Preferences: Access and update imshow preferences in


MATLAB Online
In MATLAB Online, you can set the default values for these aspects of images displayed using
imshow:

• Axes visible — Control whether imshow displays images with the axes box outline and tick labels.
• Border Style — Control whether imshow draws a tight or loose border around images in the
figure window.
• Initial Magnification — Control whether imshow initially fits images to the figure window or
magnifies them by a specified percentage.

To open these image display preferences, on the Home tab, in the Environment section, click
Preferences. Select MATLAB > Image Display.

2-25
R2023a

Functionality being removed or changed


BaseValue property of bar, stem, and area plots no longer changes with axes limits
Behavior change

The BaseValue property of bar, stem, and area plots no longer depends on the axes limits. The
property value stays the same when you change axes limits or pan within the axes.

This change does not affect the appearance of the plots, but it provides a more predictable
experience when you change the axes limits or pan within the axes.

MATLAB Online limits imshow image display resolution


Behavior change

MATLAB Online limits the maximum imshow image display resolution to improve rendering speeds
for large images. This behavior affects the on-screen display, but it does not affect the image data.
Before displaying an image, imshow resizes the largest dimension to a maximum size of 512 pixels.
The smaller dimension adjusts to preserve the aspect ratio of the image. To view images at their full
resolution, use MATLAB desktop or set the MaxRenderedResolution property of the output Image
object to "none". For details about the MaxRenderedResolution property, see Image Properties.

Plot Catalog tool will be removed


Warns

The Plot Catalog tool will be removed in a future release. Instead, to interactively create and explore
visualizations for your data, use the Plots tab in the MATLAB Toolstrip or the Create Plot task in the
Live Editor.

For more information about visualizations, see Types of MATLAB Plots or toolbox-specific
documentation.

Figure Tools menu will no longer include interaction modes and options
Still runs

In a figure, the Tools menu will no longer contain these items in a future release:

• Zoom In
• Zoom Out
• Pan
• Rotate 3D
• Data Tips
• Brush
• Restore View
• Options
• Align Distribute Tool

Instead, to enable interaction modes, use the axes toolbar. Customize the interaction by right-clicking
in the chart when an interaction mode is enabled, or for apps, by using the InteractionOptions
property of the axes.

2-26
App Building

App Building

addStyle Function: Add styles to items in list box or drop-down UI


component
Create styles for specific items in a list box or drop-down UI component using the uistyle and
addStyle functions. For example, you can add icons to items in a list box. To get information on
applied styles, query the StyleConfigurations property of the ListBox or DropDown object. To
remove a style from a component, use the removeStyle function.

uistack Function: Change stacking order of UI components in UI figure


You can now use the uistack function to change the stacking order of UI components and
containers in a figure created using the uifigure function. Previously, uistack supported UI
components only in figures created using the figure function.

uipanel and uibuttongroup Functions: Specify container border color


You can specify the border color of panels and button groups by using the BorderColor property.
For more information, see Panel Properties or ButtonGroup Properties.

uihtml Function: Send events between MATLAB and HTML


When you create an HTML UI component using the uihtml function, you can send events between
MATLAB and HTML. Send events when a specific action occurs to one object and another object
needs to know about or react to that action. For example, you can send an event from HTML to
MATLAB whenever a user clicks a button HTML element, and then write a callback in MATLAB that
updates your app in response. You also can send an event from MATLAB to HTML whenever a user
clicks a Button UI component in your app, and then write a callback in your HTML source file that
updates the HTML code in response.

To send an event from HTML to MATLAB, call the sendEventToMATLAB function on the
htmlComponent JavaScript® object in your setup method.

htmlComponent.sendEventToMATLAB(eventName,eventData)

React to this event by writing MATLAB code that creates an HTMLEventReceivedFcn callback for
the HTML MATLAB object.

comp.HTMLEventReceivedFcn = @myCallbackFunction

To send an event from MATLAB to HTML, call the sendEventToHTMLSource function on the HTML
MATLAB object.

sendEventToHTMLSource(comp,eventName,eventData)

React to this event by writing JavaScript code in your setup method that listens for the event and
executes a callback function in response.

htmlComponent.addEventListener(eventName,eventData,callbackFunction)

2-27
R2023a

For more information, see Send Event from JavaScript to MATLAB and Send Event from MATLAB to
JavaScript.

uiimage Function: Specify image alt text for use with screen readers
Provide a description of an image created using the uiimage function by specifying the AltText
property. This property is used by screen readers to describe the image when an app user navigates
through the app.

appmigration.migrateGUIDEApp Function: Programmatically migrate


existing GUIDE apps to App Designer
Programmatically migrate existing GUIDE apps to App Designer apps by using the
appmigration.migrateGUIDEApp function. You can specify a single app, multiple apps, or a folder
of apps to migrate as a batch. The function uses the GUIDE to App Designer Migration Tool for
MATLAB to perform the migration.

App Designer: View progress when loading an app


When you load an app in App Designer, a progress bar now displays an estimate of its loading
progress.

App Designer: Add label to unlabeled UI component


To add a label to a UI component without one, in Design View, right-click the component and select
Add Label or use the keyboard shortcut Ctrl+L.

App Designer: Replace assigned callback with new callback


You can now more efficiently create a new callback for a UI component that already has a callback
assigned. To replace an existing callback with a new one, select the component in the Component
Browser and, in the Callbacks tab, select the option to add a callback. For example, for a component
with a ButtonPushedFcn callback already assigned, select <add ButtonPushedFcn callback>
from the associated drop-down list. App Designer creates a new callback function, assigns it to the
component, and unassigns the previous callback function.

2-28
App Building

Previously, you had to first unassign the assigned callback from the component before creating a new
callback.

App Testing Framework: Test context menus within labels


You can use the chooseContextMenu method to test a right-click that opens a context menu within
label components. For example, assign a context menu with two items to a label, and then choose the
first menu item.

fig = uifigure;
lbl = uilabel(fig);

cm = uicontextmenu(fig);
m1 = uimenu(cm,Text="Menu1");
m2 = uimenu(cm,Text="Menu2");
lbl.ContextMenu = cm;

testCase = matlab.uitest.TestCase.forInteractiveUse;
testCase.chooseContextMenu(lbl,m1)

Axes Interactions: Customize behavior of interactions with axes view


For apps created in App Designer and using the uifigure function, customize axes interaction
behavior using the InteractionOptions property of the axes. Customize the behavior of panning,
zooming, rotating, adding data tips, data brushing, and restoring the original view by setting the
value of InteractionOptions properties. For a complete list of properties, see
InteractionOptions Properties.

The options set by the InteractionOptions object apply to these interactions on the associated
axes:

• The built-in interactions specified by the Interactions property of the axes


• Interactions enabled by using mode functions, such as pan and zoom
• Interactions enabled using the axes toolbar

For example, limit all pan and zoom interactions to the x-dimension only.

fig = uifigure;
ax = uiaxes(fig);
ax.InteractionOptions.LimitsDimensions = "x";

Plots in Apps: Enable data cursor mode


For apps created in App Designer and using the uifigure function, use data cursor mode to
interactively create and edit data tips. For supported charts, select the Data Tips icon in the axes
toolbar or use the datacursormode function.

2-29
R2023a

Plots in Apps: Specify axes for interaction mode


For apps created in App Designer and using the uifigure function, set the interaction mode for
axes. Specify the Axes object as the first argument for these functions:

• pan
• zoom
• rotate3d
• datacursormode
• brush

For example, for a figure with two axes, enable pan mode for only axes ax1.

fig = uifigure;
t = tiledlayout(fig,1,2);
ax1 = nexttile(t);
ax2 = nexttile(t);
pan(ax1,"on")

When setting the interaction mode for axes, these functions do not return pan, zoom, rotate3d,
DataCursorManager, or brush objects. Previously, these functions set the interaction mode for all
Axes children of the current or target figure.

Functionality being removed or changed


uistack function has different stacking behavior for menus, toolbars, push tools, and toggle
tools
Behavior change

When you modify the stacking order of menus, toolbars, push tools, and toggle tools using the
uistack function, the behavior is different than in previous releases. For example, starting in
R2023a, calling uistack(comp,"up") has this behavior:

• Menu items parented to a figure — The menu item moves one place to the left in the menu bar.
Previously, the menu item moved one place to the right.
• Menu items parented to a context menu — The menu item moves one place up in the context
menu. Previously, the menu item moved one place down.
• Toolbars — The toolbar moves one place up within the collection of toolbars in the figure.
Previously, the toolbar moved one place down.
• Push tools and toggle tools — The push tool or toggle tool moves one place to the left in the
toolbar. Previously, the push tool or toggle tool moved one place to the right.

If your code uses uistack to modify the stacking order of menus, toolbars, push tools, or toggle
tools, make these updates to the code to retain the previous behavior.

Original Code in R2022b or Earlier Updated Code in R2023a


uistack(comp,"top") uistack(comp,"bottom")
uistack(comp,"up",step) uistack(comp,"down",step)
uistack(comp,"bottom") uistack(comp,"top")

2-30
App Building

Original Code in R2022b or Earlier Updated Code in R2023a


uistack(comp,"down",step) uistack(comp,"up",step)

HighlightColor property of panel and button group containers is not recommended


Still runs

Using the HighlightColor property to specify the border color of a panel or button group is not
recommended. Use the BorderColor property instead. The BorderColor property has the same
effect and accepts the same values as the HighlightColor property. For more information, see
Panel Properties or ButtonGroup Properties.

There are no plans to remove support for the HighlightColor property at this time. However, the
HighlightColor property no longer appears in the list returned by calling the get function on a UI
container.

2-31
R2023a

Performance

Language and Programming: Improved performance when calling


functions and methods
Calling most functions and methods shows improved performance. For example, in a file named
myFun.m in your current folder, create the myFun function.

function y = myFun(x)
y = x;
end

In a file named timingTest.m in your current folder, create a function that calls myFun. The
timingTest function is about 1.6x faster than in the previous release.

function out = timingTest


n = 1e7;
for i = 1:n
out = myFun(3);
end
end

The approximate execution times are:

R2022b: 0.18 s

R2023a: 0.11 s

The code was timed on a Windows 10, Intel Xeon CPU E5-1650 v4 @ 3.60 GHz test system using the
timeit function.

timeit(@timingTest)

Function Handles: Improved performance when invoking handles to


named functions
Invoking handles to named functions that are not nested shows improved performance. Invoking such
function handles no longer results in an overhead compared to calling functions directly. For example,
in a file named myFun.m in your current folder, create the myFun function.

function y = myFun(x)
y = x;
end

In a file named timingTest.m in your current folder, create a function that invokes a handle to
myFun. The timingTest function is about 40x faster than in the previous release.

function t = timingTest
f = @myFun;
n = 1e7;
tic
for i = 1:n
out = f(3);
end

2-32
Performance

t = toc;
end

The approximate execution times are:

R2022b: 4.4 s

R2023a: 0.11 s

The code was timed on a Windows 10, Intel Xeon CPU E5-1650 v4 @ 3.60 GHz test system by calling
the timingTest function.

varargin Argument: Improved performance when specifying zero or


more inputs
Specifying a variable number of input arguments using varargin shows improved performance. For
example, in a file named timingTest.m in your current folder, create a function that expects one
input and accepts an additional number of inputs.

function timingTest(x,varargin)
n = 1e6;
tic
for i = 1:n
y = myFun(x,varargin{:});
end
toc
end

function y = myFun(x,varargin)
if nargin == 1
y = x;
elseif nargin == 3
y = x + varargin{1} + varargin{2};
else
y = NaN;
end
end

The amount of improvement depends on whether varargin is empty. The performance improvement
is most significant when varargin is empty.

• Empty varargin — Time this code by running timingTest(1). The code is about 22x faster
than in the previous release. The approximate execution times are:

R2022b: 0.404 s

R2023a: 0.018 s
• Nonempty varargin — Time this code by running timingTest(1,2,3). The code is about 2x
faster than in the previous release. The approximate execution times are:

R2022b: 1.428 s

R2023a: 0.734 s

The code was timed on a Windows 10, Intel Xeon CPU E5-1650 v4 @ 3.60 GHz test system.

2-33
R2023a

timetable Data Type Indexing: Improved performance when


subscripting with times or with withtol subscript
timetable subscripting when subscripting with times or with a withtol subscript is significantly
faster in R2023a than in R2022b.

• For example, when you use a vector of 100 datetime values to subscript into a timetable that has
107 rows, performance in R2023a is about 114x faster than in R2022b.
function timingTest()
rng default

% 10^7 rows
N = 10000000;
rowtimes = datetime(2023,1,1,0,0,0:N-1);
rowtimes.Format = rowtimes.Format + ".SSS";
tt = timetable(rand(N,1),RowTimes=rowtimes);

% 100 values chosen in steps of 10


n = 1000;
t = datetime(2023,1,1,0,0,0:10:n-1);

tic
tt2 = tt(t,:);
toc
end

The approximate execution times are:

R2022b: 9.10 s

R2023a: 0.08 s
• Similarly, when you use a vector of 100 duration values to subscript into a timetable that has 107
rows, performance in R2023a is about 14x faster than in R2022b.
function timingTest()
rng default

% 10^7 rows
N = 10000000;
rowtimes = seconds(0:N-1);
tt = timetable(rand(N,1),RowTimes=rowtimes);

% 100 values chosen in steps of 10


n = 1000;
t = seconds(0:10:n-1);

tic
tt2 = tt(t,:);
toc
end

The approximate execution times are:

R2022b: 1.29 s

R2023a: 0.09 s

2-34
Performance

• When you use a withtol subscript with a timetable that has 107 rows, performance in R2023a is
about 44x faster than in R2022b.

function timingTest()
rng default

% 10^7 rows
N = 10000000;
rowtimes = seconds(0:N-1);
tt = timetable(rand(N,1),RowTimes=rowtimes);

% 100 values chosen in steps of 10


n = 1000;
t = seconds(0:10:n-1);

tt.Time = tt.Time + .1*seconds(rand(N,1));


wt = withtol(t,seconds(.1));

tic
tt2 = tt(wt,:);
toc
end

The approximate execution times are:

R2022b: 3.92 s

R2023a: 0.09 s

The code was timed on a Windows 10, AMD® EPYC 74F3 24-Core Processor @ 3.19 GHz test system
by calling each version of the timingTest function.

Complex Matrices: Improved performance when using colon indexing


to copy complex matrices
Copying a complex matrix using colon indexing shows improved performance. This improvement is
greater for larger matrices.

For example, this code is about 105x faster than in the previous release.

a = rand(100)*1j;

tic;
for i = 1:1e6
b = a(:,:);
end
toc;

The approximate execution times are:

R2022b: 22.3 s

R2023a: 0.212 s

This improvement is most noticeable when the copy is not modified. However, examples like these
still execute noticeably faster.

2-35
R2023a

• Modify no elements of the copy based on a conditional (95x improvement).


a = rand(100)*1j;

tic;
for k = 1:1e6
b = a(:,:);
if (isreal(b(1,1)))
b(1,1) = b(1,1)*1j;
end
toc;

R2022b: 21.3 s

R2023a: 0.223 s
• Modify an element of the copy based on a conditional (2x improvement).
a = rand(100)*1j;

tic;
for k = 1:1e6
b = a(:,:);
if (~isreal(b(1,1)))
b(1,1) = b(1,1)*1j;
end
toc;

R2022b: 23.5 s

R2023a: 10.1 s
• Use an implicit copy in an operation (4x improvement).
a = rand(100)*1j;
b = rand(100)*1j;

tic;
for k = 1:1e6
c = a(:,:) + b;
end
toc;

R2022b: 41.1 s

R2023a: 9.87 s
• Resize from 4-D to 2-D during copy (63x improvement).
a = rand(10,10,10,10)*1j;

tic;
for k = 1:1e6
b = a(:,:);
end
toc;

R2022b: 28.2 s

R2023a: 0.451 s

2-36
Performance

The code was timed on a Windows 10, Intel Xeon CPU E5-2650 v2 @ 2.60 GHz test system.

mean, std, var, and rmse Functions: Improved performance when


computing along default vector dimension
The mean, std, var, and rmse functions show improved performance when computing over a real
vector when the operating dimension is not specified. The functions determine the default operating
dimension more quickly in R2023a than in R2022b.

For example, this code computes the mean along the default vector dimension. The code is about 2.2x
faster than in the previous release.

function timingMean
A = rand(10,1);
for i = 1:8e5
mean(A);
end
end

The approximate execution times are:

R2022b: 0.91 s

R2023a: 0.41 s

The code was timed on a Windows 10, Intel Xeon CPU E5-1650 v4 @ 3.60 GHz test system using the
timeit function.

timeit(@timingMean)

Moving Statistics Functions: Improved performance when computing


over matrix with sample points
Moving statistics functions show improved performance when computing over a matrix when there
are sample points. These functions show improved performance:

• movmin
• movmax
• movmean
• movmedian
• movmad
• movstd
• movvar
• movsum
• movprod

For example, this code computes the moving sums of a 300-by-300 matrix with corresponding sample
points. The code is about 3x faster than in the previous release.

function timingMovsum
A = randn(300);

2-37
R2023a

t = sort(rand(300,1));
tic
for k = 1:2000
movsum(A,0.1,"SamplePoints",t);
end
toc
end

The approximate execution times are:

R2022b: 1.04 s

R2023a: 0.34 s

The code was timed on a Windows 10, Intel Xeon CPU E5-1650 v4 @ 3.60 GHz test system by calling
the timingMovsum function.

histcounts Function: Improved performance with small numeric and


logical input data
The histcounts function shows improved performance for numeric and logical data due to faster
input parsing. The performance improvement is more significant when input parsing is a greater
portion of the computation time. This situation occurs when the size of the data to distribute among
bins is smaller than 2000 elements.

For example, this code calculates histogram bin counts for a 1000-element vector. The code is about
3x faster than in the previous release.

function timingHistcounts
X = rand(1,1000);
for k = 1:3e3
histcounts(X,"BinMethod","auto");
end
end

The approximate execution times are:

R2022b: 0.62 s

R2023a: 0.21 s

The code was timed on a Windows 10, Intel Xeon CPU E5-1650 v4 @ 3.60 GHz test system using the
timeit function.

timeit(@timingHistcounts)

fzero function: Improved performance


The fzero function shows improved performance. The performance improvement is most significant
when the objective function is fast to compute and fzero does not use an options argument.

For example, this code runs about 4x faster than in the previous release.

rng default
N = 1e5;

2-38
Performance

levels = 1.5 * rand(N,1);


out = zeros(N,1);
myfun = @(x,lv)x*sin(x)-lv;
tic
for i=1:N
out(i) = fzero(@(x)myfun(x,levels(i)),0);
end
toc

The approximate execution times are:

R2022b: 2.67 s

R2023a: 0.63 s

The code was timed on a Windows 10, Intel Xeon CPU E5-1650 v3 @ 3.5 GHz test system.

Plots in Apps: Improved performance when rerendering axes


Axes rerender more quickly in R2023a than in R2022b. The reduced rerendering time is most
noticeable when many sequential updates to the axes occur.

For example, first create axes to specify as the input to the timingAnimation function. Then, call
the timingAnimation function to add points to an animated line. The time for the axes to rerender
is reduced, resulting in an animation that is about 1.35x faster in R2023a than in the previous
release.
function timingAnimation(ax)
h = animatedline(ax);
x = linspace(0,4*pi,1000);
y = sin(x);
tic
for k = 1:length(x)
addpoints(h,x(k),y(k));
drawnow
end
toc
end

The approximate durations of the animation are:

R2022b: 5.66 s

R2023a: 4.20 s

The code was timed on a Windows 10, Intel Xeon CPU E5-1650 v4 @ 3.60 GHz test system by calling
the timingAnimation function.

Plots in Apps: Improved performance when creating axes


Axes render more quickly within apps and within figures created with the uifigure function in
R2023a than in R2022b. The delay before the axes appear in an existing figure is reduced.

For example, if you run the code uiaxes(f) for an existing figure f, the axes appear about 3.7x
faster in R2023a than in R2022b when creating axes for the first time in a MATLAB session and about
2.4x faster for subsequent axes.

2-39
R2023a

The approximate axes rendering times are:

First Axes Subsequent Axes


R2022b 14.94 s 1.06 s
R2023a 4.02 s 0.44 s

These operations were timed on a Windows 10, Intel Xeon CPU E5-1650 v4 @ 3.60 GHz test system.

Plots in Apps: Improved responsiveness of ruler-pan interaction


The ruler-pan interaction is faster and smoother within apps and within figures created with the
uifigure function in R2023a than in R2022b. The improvement is most noticeable for plots that
display a large number of data points.

For example, this code creates a figure with a plot of a 2500-by-2500 matrix. When you pan the ruler,
the ruler-pan interaction is smoother and the axes track your mouse motion more closely in R2023a
than in the previous release.

f = uifigure;
ax = uiaxes(f);
p = peaks(2500);
plot(ax,p)

R2022b R2023a
When panning the ruler, the surface plot takes a When panning the ruler, the surface plot follows
moment to reposition and jumps to the new the mouse motion more closely and repositions
location. more quickly at the new location.

The ruler-pan interaction was performed on a Windows 10, Intel Xeon CPU E5-1650 v4 @ 3.60
GHz test system by running the above script and panning the y-axis ruler.

2-40
Performance

Live Editor: Improved performance when filtering numeric table


variables
In the output of the Live Editor, the performance of filtering a numeric table or timetable variable is
improved. When dragging the maximum or minimum value slider, the drag interaction is smoother
and faster in R2023a than in R2022b, and the data tip displaying the current slider value appears to
the side of the filtering figure.

For example, for a table output in the Live Editor, pause on the header of a numeric variable and click
the triangle icon. Then, to filter the data, adjust the maximum value by dragging the slider. The drag
interaction is smoother and tracks your mouse motion more closely in R2023a than in the previous
release.

R2022b R2023a
After dragging the maximum value slider in a After dragging the maximum value slider in a
filtering figure, the slider takes a moment to filtering figure, the slider follows the mouse
reposition and jumps to the new location. The motion more closely and repositions more quickly
associated data tip moves with the slider and at the new location. The associated data tip is
obscures the filtering figure. located in a fixed position to the right of the
filtering figure.

The filtering interaction was performed on a Windows 10, Intel Xeon CPU E5-1650 v4 @ 3.60
GHz test system by dragging the maximum value slider in the filtering figure for a 1000-row numeric
table variable.

Property Inspector: Improved performance when opening for the first


time
The Property Inspector shows improved performance when opening for the first time in a MATLAB
session. The delay between clicking the Property Inspector icon or calling inspect and the inspector
being ready is reduced.

2-41
R2023a

For example, open the Property Inspector for the first time in a MATLAB session. You can use the
Property Inspector 1.17x sooner than in the previous release.

ax = axes;
inspect(ax)

The approximate rendering times are:

R2022b: 13.5 s

R2023a: 11.5 s

The rendering of the Property Inspector was timed on a Windows 10, Intel Xeon CPU E5-1650 v4 @
3.60 GHz test system by running the code and measuring the time it takes for the edit fields to appear
in the Property Inspector.

Property Inspector: Improved performance when switching between


objects
The Property Inspector shows improved performance when switching between objects. The delay
between selecting a different object and an existing instance of the Property Inspector rendering the
properties of the newly selected object is reduced.

For example, open the Property Inspector. Then, create and inspect an Axes object. The axes
properties render 1.7x faster than in the previous release.

inspect
ax = axes;
inspect(ax)

The approximate times for the Property Inspector to render the properties of the axes are:

R2022b: 3.5 s

R2023a: 2.1 s

The rendering of the Property Inspector was timed on a Windows 10, Intel Xeon CPU E5-1650 v4 @
3.60 GHz test system by running the code and measuring the time it takes for the Property Inspector
to be ready.

Variables Editor: Improved performance of cell editing in MATLAB


Online
In the MATLAB Online Variables editor, when you interactively edit the value of a cell, the cell
updates to display the new value more quickly in R2023a than in R2022b.

For example, create a 1000-element cell array and open the cell array in the Variables editor.

C = cell(1000);
openvar C

Then, double-click on a cell and enter a new value. On a Windows 10, Intel Xeon CPU E5-1650 v4 @
3.60 GHz test system, when you move the focus from the edited cell, the cell value updates
immediately. In R2022b, the cell value updates after a 3.5-second delay.

2-42
Performance

Variables Editor: Improved speed of data display when scrolling in


MATLAB Online
In the MATLAB Online Variables editor, the performance of vertical and horizontal scrolling is
improved. When scrolling within 1000 rows below the current element or 100 variables to the right of
the current element, the data appears more quickly in R2023a than in R2022b.

For example, create a 1000-by-1000 matrix and open the matrix in the Variables editor.

X = rand(1000);
openvar X

When you scroll down 100 rows, the values of all visible matrix elements in the Variables editor are
rendered about 6.7x faster than in the previous release.

The approximate times for the Variables editor to render the values of all visible matrix elements are:

R2022b: 1.80 s

R2023a: 0.27 s

This interaction was timed on a Windows 10, Intel Xeon CPU E5-1650 v4 @ 3.60 GHz test system by
running the above script and scrolling in the Variables editor.

App Building: Improved app startup performance


Apps created in App Designer and using the uifigure function start up faster in R2023a than in
R2022b and previous releases. The improvement is more noticeable for apps with many UI
components.

For example, this code creates an app with 1000 edit field components. The code is about 1.5x faster
than in the previous release and about 3x faster than in R2021b.

function timingApp
fig = uifigure;
gl = uigridlayout(fig,Scrollable="on");
gl.RowHeight = repmat({'fit'},1,100);
gl.ColumnWidth = repmat({'fit'},1,10);

for k = 1:1000
uieditfield(gl);
end
end

The approximate execution times are:

R2021b: 21.5 s

R2022b: 10.6 s

R2023a: 7.2 s

The code was timed on a Windows 10, Intel Xeon CPU E5-1650 v4 @ 3.60 GHz test system by running
the timingApp function and measuring the time it takes for the edit fields to appear in the UI figure
window.

2-43
R2023a

App Building: Improved startup performance for apps with multiple


tabs
In addition to the overall app startup performance improvement in R2023a, some apps that contain
multiple tabs show an even greater startup performance improvement. The reason is that MATLAB
prioritizes creating the content in the visible tab over non-visible content when the app first runs.

The particular performance improvement that you see depends on the app layout and UI component
types. The improvement is more noticeable for apps with these types of UI components in unselected
tabs:

• Labels and spinners with a grid layout manager


• Table UI components without a grid layout manager

For example, this code creates a tab group with five tabs, each containing 200 label components. The
code is about 1.9x faster than in the previous release.

function timingTabApp
fig = uifigure;
tg = uitabgroup(fig);

for k1 = 1:5
t = uitab(tg);
gl = uigridlayout(t,Scrollable="on");
gl.RowHeight = repmat({'fit'},1,20);
gl.ColumnWidth = repmat({'fit'},1,10);
for k2 = 1:200
uilabel(gl);
end
end
end

The approximate execution times are:

R2022b: 9.8 s

R2023a: 5.2 s

The code was timed on a Windows 10, Intel Xeon CPU E5-1650 v4 @ 3.60 GHz test system by running
the timingTabApp function and measuring the time it takes for the components to appear in the UI
figure window.

If you have an app with many UI components, consider updating your app layout to take advantage of
this improvement. For more information, see Improve App Startup Time.

Compatibility Considerations
When an app user switches to a new tab for the first time after running an app, the interaction might
take more time than in previous releases. The reason is that MATLAB might create some content in
the tab only after the user selects the tab. If the user later switches to the same tab again, the
interaction does not take the additional time.

2-44
Performance

App Building: Improved performance when resizing some apps


When a user resizes an app figure window, some apps reposition their content faster in R2023a than
in R2022b. The types of apps that show this improvement are:

• Large apps with tabs that have an AutoResizeChildren value of 'on'


• Large apps with panels and button groups that have a SizeChangedFcn callback

For example, this code creates an app with a tab group where each tab contains many edit fields that
are resized automatically. The resize operation is smoother and faster in R2023a than in the previous
release.

function tabResize
fig = uifigure;
tg = uitabgroup(fig,"Position",[20 20 400 375]);
for k1 = 1:5
t = uitab(tg,"Scrollable","on");
for k2 = 1:100
ef = uieditfield(t,"Position",[50 22*k2 250 20]);
end
end
end

R2022b R2023a
When the app resizes, the app content takes When the app resizes, the app content takes less
multiple seconds to reposition. than one second to reposition.

As another example, this code creates an app with many panels, each of which resizes a button using
a SizeChangedFcn callback whenever the app size changes. The resize operation is smoother and
faster in R2023a than in the previous release.

function panelResize
fig = uifigure("AutoResizeChildren","off", ...

2-45
R2023a

"SizeChangedFcn",@resizePanels);
for k = 1:225
p = uipanel(fig, ...
"AutoResizeChildren","off", ...
"SizeChangedFcn",@resizeButtons);
btn = uibutton(p,"Position",[2 2 20 20]);
end
end

function resizeButtons(src,~)
for k = 1:length(src.Children)
src.Children(k).Position(3:4) = 0.9*src.Position(3:4);
end
end

function resizePanels(src,~)
xscale = src.Position(3)/15;
yscale = src.Position(4)/15;
for k = 1:length(src.Children)
p = src.Children(k);
p.Position = [xscale*(mod((k-1),15)), ...
yscale*(floor((k-1)/15)), ...
xscale, ...
yscale];
end
end

R2022b R2023a
When the app resizes, the app content takes When the app resizes, the app content takes
multiple seconds to reposition. about one second to reposition.

The resize interactions were performed on a Windows 10, Intel Xeon CPU E5-1650 v4 @ 3.60 GHz
test system by running the tabResize and panelResize functions and resizing the figure window.

2-46
Software Development Tools

Software Development Tools

Build Automation: Improve build speed and efficiency with


incremental builds
The build tool supports incremental builds. Incremental builds avoid redundant work by skipping
tasks that are up to date. If you want the build tool to skip a task when it is up to date, specify the
inputs or outputs of the task. The build tool keeps track of the inputs and outputs every time the task
runs and skips the task if they have not changed. For more information, see Improve Performance
with Incremental Builds.

Build Automation: Create and run tasks that accept arguments


The build tool lets you create and run tasks that accept arguments. You can use task arguments to
customize the actions that tasks perform when they run. For more information, see Create and Run
Tasks That Accept Arguments.

Dependency Analyzer: Analyze files and folders with or without a


project
Starting in R2023a, you can access Dependency Analyzer from the MATLAB apps gallery. You can
now perform a dependency analysis on files and folders that do not belong to a project. For more
information, see Dependency Analyzer.

Project Preferences: Recreate empty project folders in Git repositories


Git does not track empty folders and ignores them when you commit. MATLAB now enables you to
recreate an empty folder structure in a project under Git source control. Doing so is useful for small
projects intended for training or as procedure templates.

For large projects, to avoid performance issues on startup, clear Recreate empty project folders in
a project under Git. For more information, see Set MATLAB Projects Preferences.

Project API: Determine if file is under project root folder


You can now programmatically determine whether a file or a folder is under a project root folder by
using the matlab.project.isUnderProjectRoot function.

Project API: Export subset of project files to archive


You can now programmatically export a subset of project files to an archive by specifying a user-
defined export profile in the export function.

2-47
R2023a

Project Sharing: Include only specific files in project archive using


export profile
You can now use an export profile to include only files with particular labels in a project archive. This
option is useful if the files you need to share are only a small subset of a large project. For more
information, see Create an Export Profile.

Comparison Tool: Automate comparison report generation for


continuous integration (CI) workflows
Starting in R2023a, you can programmatically publish comparison reports for plain text files,
MATLAB scripts, and text-based source code files. Automate report generation for continuous
integration (CI) workflows using the visdiff function.

comparison = visdiff(textfile1,textfile2);
file = publish(comparison);
web(file)

Source Control in MATLAB Online: Save uncommitted changes by


creating a Git stash
In MATLAB Online, you can now save uncommitted changes by creating a Git stash.

Source Control in MATLAB Online: Manage Git remote repositories


locally using Branch Manager
In MATLAB Online, you can now manage multiple remote repositories from a local Git repository. Use
Branch Manager to perform these tasks:

• Add, edit, and delete remote repositories.


• Fetch from all remotes or individual remotes.
• Prune remote branches from all or individual remotes.
• Open selected remotes in a web browser.
• Create new local branches that track remote branches.
• Delete remote branches.

Source Control in MATLAB Online: Detect and extract conflict markers


from text and binary files
In MATLAB Online, you can now detect conflict markers added by Git in text and binary files. Extract
conflict markers to repair corrupted files.

Comparison Tool in MATLAB Online: Compare project definition files


Starting in R2023a, when you compare folders in MATLAB Online, MATLAB detects whether they are
project root folders. MATLAB looks for and compares the project definition files stored in the
resources or .SimulinkProject folder. Project definition files contain information about the

2-48
Software Development Tools

project path, project settings, shortcuts, labels, and referenced projects. For more information, see
Compare MATLAB Projects in MATLAB Online.

Dependency Analyzer in MATLAB Online: Investigate circular


dependencies using the Project Hierarchy view
You can now investigate how projects in your hierarchy relate to each other and identify projects that
introduce circular dependencies using the Project Hierarchy view in MATLAB Online. For more
information, see Analyze Project Dependencies.

Unit Testing Framework: Run tests interactively by using Test Browser


The Test Browser app enables you to run script-based, function-based, and class-based tests
interactively. You can use the test browser to:

• Create a test suite from files and folders.


• Run all or part of the specified tests.
• Access diagnostics and debug test failures.
• Customize a test run with options, such as running tests in parallel (requires Parallel Computing
Toolbox) or specifying a level of test output detail.
• Generate an HTML code coverage report for MATLAB source code.

For more information, see Run Tests Using Test Browser.

2-49
R2023a

Unit Testing Framework: Programmatically access code coverage


results
You can use the matlab.unittest.plugins.codecoverage.CoverageResult class to
programmatically access the results of code coverage analysis for your source code. To generate and
access the coverage results, create a CodeCoveragePlugin instance using a CoverageResult
object, and add the plugin to the test runner. After the test run, the Result property of the
CoverageResult object holds the coverage results as an array of matlab.coverage.Result
objects. Each element of the array provides information about one of the files in your source code
that was covered by the tests.

For more information, see Collect Statement and Function Coverage Metrics for MATLAB Source
Code.

Unit Testing Framework: Temporarily set environment variables


The matlab.unittest.fixtures.EnvironmentVariableFixture class provides a fixture for
setting an operating system environment variable. Once the testing framework tears down the
fixture, the fixture restores the environment variable to its original state.

Unit Testing Framework: Test for handle validity


The matlab.unittest.constraints.IsValid class provides a constraint to test if a handle array
is valid. The constraint is satisfied if all array elements are valid handles.

Unit Testing Framework: Write text to files in thread-based


environment
You can use the ToFile and ToUniqueFile classes in a thread-based environment to write text to
UTF-8 encoded files.

Unit Testing Framework: Use renamed classes in testing and other


automated workflows
To reflect support for additional automated workflows, a group of matlab.unittest classes have
been renamed. For example, matlab.unittest.Verbosity is now named
matlab.automation.Verbosity.

This table shows the affected classes and their new names. The behavior of these classes remains the
same, and existing instances of these classes in your code continue to work as expected. There are no
plans to remove support for existing instances of these classes.

R2022b and Earlier Starting in R2023a


matlab.unittest.Verbosity matlab.automation.Verbosity
matlab.unittest.diagnostics.Diagnostic matlab.automation.diagnostics.Diagnost
ic
matlab.unittest.diagnostics.Diagnostic matlab.automation.diagnostics.Diagnost
Result icResult

2-50
Software Development Tools

R2022b and Earlier Starting in R2023a


matlab.unittest.diagnostics.DisplayDia matlab.automation.diagnostics.DisplayD
gnostic iagnostic
matlab.unittest.diagnostics.FileArtifa matlab.automation.diagnostics.FileArti
ct fact
matlab.unittest.diagnostics.FunctionHa matlab.automation.diagnostics.Function
ndleDiagnostic HandleDiagnostic
matlab.unittest.diagnostics.StringDiag matlab.automation.diagnostics.StringDi
nostic agnostic
matlab.unittest.plugins.OutputStream matlab.automation.streams.OutputStream
matlab.unittest.plugins.ToFile matlab.automation.streams.ToFile
matlab.unittest.plugins.ToStandardOutp matlab.automation.streams.ToStandardOu
ut tput
matlab.unittest.plugins.ToUniqueFile matlab.automation.streams.ToUniqueFile

App Testing Framework: Test context menus within labels


You can use the chooseContextMenu method to test a right-click that opens a context menu within
label components. For example, assign a context menu with two items to a label, and then choose the
first menu item.

fig = uifigure;
lbl = uilabel(fig);

cm = uicontextmenu(fig);
m1 = uimenu(cm,Text="Menu1");
m2 = uimenu(cm,Text="Menu2");
lbl.ContextMenu = cm;

testCase = matlab.uitest.TestCase.forInteractiveUse;
testCase.chooseContextMenu(lbl,m1)

Performance Testing Framework: Use fewer samples to meet the


objective margin of error
The default number of times that the framework exercises the test code to warm it up in a frequentist
time experiment (created using either the runperf function or the limitingSamplingError static
method) has increased from four to five. This change results in typically fewer samples required to
meet the objective relative margin of error.

Compatibility Considerations
If your code relies on the previous default value, you might need to update your code. For example, if
you use warmupTable = results(1).TestActivity(1:4,:) to create a table of warm-up
measurements, replace 4 with 5. Also, if you want to keep using the previous default value, explicitly
specify the value in your code. This table shows an example of how to update code that runs tests
using four warm-up measurements.

2-51
R2023a

Before After
import matlab.perftest.TimeExperiment import matlab.perftest.TimeExperiment
experiment = TimeExperiment.limitingSamplingError;
experiment = TimeExperiment.limitingSamplingError("Nu
results = run(experiment,mySuite); results = run(experiment,mySuite);

Functionality being removed or changed


TaskAction constructor method has been removed
Errors

The constructor method of the matlab.buildtool.TaskAction class has been removed. To specify
a task action, use a function handle instead of the constructor method. This table shows an example
of how to update code that calls the TaskAction constructor method.

Before After
import matlab.buildtool.Task import matlab.buildtool.Task
import matlab.buildtool.TaskAction
plan = buildplan;
plan = buildplan; plan("test") = Task( ...
plan("test") = Task( ... Actions=@(~)assertSuccess(runtests(IncludeSubfold
Actions=TaskAction( ...
@(~)assertSuccess(runtests(IncludeSubfolders=true)),Name="Testing"));

2-52
External Language Interfaces

External Language Interfaces

Publish C++ Interface: Publish interface for C++ library in Live Editor
The clibPublishInterfaceWorkflow function creates a live script that guides you through the
steps to publish a MATLAB interface to a C++ library. For more information, see Steps to Publish a
MATLAB Interface to a C++ Library and Generate C++ Interface.

Interface to C++ Library: Execute C++ library functions out-of-process


Run C++ library functions in processes that are separate from the MATLAB process. For more
information, see Load C++ Library In-Process or Out-of-Process. Use out-of-process mode to call
functions in third-party libraries that are not compatible with MATLAB. Publishers can use this mode
while developing an interface, eliminating the need to restart MATLAB while testing.

Interface to C++ Library: Support for default arguments


If a C++ function is defined with default arguments, then you can call the function without providing
one or more trailing arguments. MATLAB supports default arguments for scalar integer and floating-
point types.

The MATLAB interface to C++ libraries displays default arguments in function signatures in the
library definition file and in the help text. For example, the argument arg for the function funcname
has a default value of 5.

% C++ Signature: void funcname(double arg = 5.000000)

These calls to funcname produce the same result:

clib.libname.funcname
clib.libname.funcname(5)

For more information, see Call Function with Default Arguments.

Interface to C++ Library: Support for comments in function templates


The generated help text in a MATLAB interface to a C++ library includes Doxygen comments from
template functions and template methods of a class. For information about viewing these comments,
see Display Help for MATLAB Interface to C++ Library. For information about modifying comments
when publishing an interface, see Publish Help Text for MATLAB Interface to C++ Library.

Publish C++ Interface: Put libraries on run-time path


Use the copyRuntimeDependencies function to copy dependent libraries to the run-time path so
that they are available when you test. This function collects the necessary files for distributing to end
users so that they do not have to set environment variables to call functions in the library. For
information, see Set Up and Copy Run-Time Libraries.

2-53
R2023a

Publish C++ Interface: Resolve multiple redefinition and unresolved


external symbol errors
Error messages for multiple redefinition and unresolved external symbol compiler errors provide
additional help for you to resolve the error. For more information, see Resolve Build Error: Multiple
Redefinition Linker Errors and Resolve Build Error: Unresolved External Symbols.

Publish C++ Interface: Information to debug C++ library functions


You can debug C++ library functions by using a debug-version of the MATLAB interface to the library.
For steps to build a debug-version, see Debug C++ Library from MATLAB Interface.

Publish C++ Interface: Support for MATLAB operators for C++


methods
In a MATLAB interface to a C++ library, MATLAB operators are supported when corresponding
methods are defined in a C++ class.

Operation in MATLAB Method to Define in C++ Class


a < b lt(a,b)
a > b gt(a,b)
a <= b le(a,b)
a >= b ge(a,b)
a ~= b ne(a,b)
a == b eq(a,b)

Java Interface: Support for Java 11 JDK and JRE


MATLAB supports Java 11 JDK™ and JRE. To use this version, located in the folder jre_path, call
the jenv function. At the MATLAB prompt, type:

e = jenv("jre_path")

You might have to restart your MATLAB session to change to this version.

Java Interface: jenv and matlab_jenv provide environment information


The jenv function returns a JavaEnvironment object, which contains information about the Java
program on your system. The matlab_jenv command displays Java environment information at the
operating system prompt, but it does not return the information.

Python Interface: Convert between MATLAB datetime and Python


datetime, NumPy datetime64 types
You can convert between MATLAB datetime values and Python datetime or NumPy datetime64
values. For examples, see Use MATLAB datetime Types with Python.

2-54
External Language Interfaces

Python Interface: Convert between MATLAB duration and Python


timedelta, NumPy timedelta64 types
You can convert between MATLAB duration values and Python timedelta or NumPy
timedelta64 values. For examples, see Use MATLAB duration Types with Python.

Python Objects: Use Python objects as keys in dictionary


You can use Python objects as keys in dictionaries. For more information about dictionary keys, see
dictionary.

.NET Interface: Convert between MATLAB dictionary and .NET


System.Collections.Generic.Dictionary objects
You can convert a MATLAB dictionary to a .NET dictionary. For more information, see Pass Data
to .NET Objects.

To explicitly create a .NET dictionary from a MATLAB dictionary, call the NET.createDictionary
function.

To convert a .NET dictionary to a MATLAB dictionary, see How MATLAB Handles .NET Dictionary
Objects.

.NET Objects: Use .NET objects as keys in dictionary


You can use .NET objects as keys or values in dictionaries. For more information about dictionary
keys, see dictionary.

.NET Engine: Support for MATLAB structs


Use the .NET MathWorks.MATLAB.Types.MATLABStruct class to represent MATLAB struct
objects. For examples, see Use MATLAB Structures in .NET.

Perl 5.36.0: MATLAB support on Windows


As of R2023a, MATLAB on Windows ships with an updated version of Perl, version 5.36.0, and
supports an updated version of HTML::Parser, version 3.78.

Compatibility Considerations
If you use the perl command on Windows platforms, see https://www.perl.org/ for information
about using this version of the Perl programming language. For a standard distribution of
HTML::Parser, source code, and information about using HTML::Parser, see https://
metacpan.org/pod/HTML::Parser.

2-55
R2023a

Compiler support changed for building C and C++ interfaces, MEX


files, and standalone MATLAB engine and MAT-file applications
Support Compiler Platform
Added Intel oneAPI 2023 with Microsoft Visual Studio 2019 and Windows
2022 for C, C++, and Fortran macOS
Added Intel oneAPI 2022 with Microsoft Visual Studio 2017, Windows
2019, and 2022 for C, C++, and Fortran
Added MinGW-w64 version 8.1 compiler. For installation Windows
instructions, see this MATLAB Answers™ article FAQ:
How do I install the MinGW compiler?
To be phased out Intel Parallel Studio XE for C/C++ Windows

For continued support for building your applications, consider upgrading to a supported compiler. For
an up-to-date list of supported compilers, see Supported and Compatible Compilers.

Functionality being removed or changed


Python version 2.7 is no longer supported
Errors

Support for Python version 2.7 is discontinued. For continued support for your applications, upgrade
to a supported version of Python. For supported version information, see Versions of Python
Compatible with MATLAB Products by Release.

-std=c++11 flag is no longer included in MEX options files


Behavior change

MEX options files for building C++ code with MinGW and Linux® compilers no longer include the
CXXFLAGS option -std=c++11.

MEX options files for macOS compilers include the CXXFLAGS option -std=c++14 instead.

However, you can still build MEX files with the -std=c++11 option. For example, build the MEX file
myFunc.cpp with that option.

mex myFunc.cpp 'CXXFLAGS=$CXXFLAGS -std=c++11'

Continuous console and writer output for MATLAB API for Java functions
Behavior change

When you call a MATLAB function that displays output using one of the evaluate functions in
com.mathworks.engine.MatlabEngine, then the output continuously displays on the console and
writer output stream. This behavior applies to feval, fevalAsync, eval, and evalAsync.

Before R2023a, the output displays after the MATLAB function completes.

.NET Interface: Dictionary with cell types map to .NET System.Object instead of
System.Object[]
Behavior change

2-56
External Language Interfaces

A MATLAB dictionary with entries of type cell are converted to a .NET dictionary with entries of
type System.Object. Previously, the conversion was to System.Object[]. For more information,
see Pass Data to .NET Objects and How MATLAB Handles .NET Dictionary Objects.

2-57
R2023a

Hardware Support

Support for MJPEG format in USB Webcams on Windows


Starting R2023a, the MATLAB Support Package for USB Webcams installed on a Windows machine
supports the MJPEG image format. The MJPEG format provides improved frame rates for acquiring
high-resolution images from a USB webcam.

Support for 32-bit Debian Bullseye on Raspberry Pi


MATLAB Support Package for Raspberry Pi Hardware now supports 32-bit Debian® Bullseye for
MATLAB desktop and MATLAB Online. You can now customize Debian Bullseye running on your
Raspberry Pi hardware to make it compatible with MATLAB while doing the Hardware Setup.

Support for Raspberry Pi Zero 2 W and Raspberry Pi Compute Module


4
You can now use the MATLAB Support Package for Raspberry Pi Hardware with Raspberry Pi Zero 2
W and Raspberry Pi Compute Module 4 for MATLAB desktop and MATLAB Online.

2-58
3

R2022b

Version: 9.13

New Features

Bug Fixes

Compatibility Considerations
R2022b

Environment

Live Editor Controls: Add numeric spinners to increment and


decrement variable values in live scripts
You can add numeric spinners to your live scripts to interactively increment and decrement the value
of variables. To add a numeric spinner, go to the Live Editor tab, and in the Code section, click
Control. Then, select Numeric Spinner.

For more information, see Add Interactive Controls to a Live Script.

Live Editor Tasks: Specify what code to run when control value
changes
By default, when you change a parameter in a Live Editor task, the Live Editor runs the section that
contains the task. You can now configure a Live Editor task to run all sections, run the current section
and all modified sections above that section, run the current section and all remaining sections, or to
do nothing.

To configure the task, click the Options button ( ) in the top-right corner of the task. Select Autorun
and then select from the available options. For more information, see Add Interactive Tasks to a Live
Script.

Suggestions and Completions: Change when to show suggestions and


how to accept them
Starting in R2022b, you can use Ctrl+Space to show code suggestions in the Editor, Live Editor, App
Designer, and MATLAB Online Command Window. In addition, you can change when to show
suggestions and how to accept them. On the Home tab, in the Environment section, click
Preferences. Select Editor/Debugger > Automatic Completions and in the Suggestions and
completions section, adjust one or more of the options:

• To disable showing suggestions automatically, clear the Show suggestions automatically option.
• To disable showing suggestions after you press the Tab key, clear the Use tab to show
suggestions (in addition to ctrl+space) option. When this option is cleared, you can still show
suggestions by typing Ctrl+Space.
• To disable accepting a suggestion using the Right Arrow key, clear the Use right arrow to
accept suggestions (in addition to tab and enter) option. When this option is cleared, you can
still accept a suggestion using the Tab and Enter keys.

For more information, see Code Suggestions and Completions.

3-2
Environment

Search in MATLAB Online: Access toolstrip actions, preferences, and


Help Center resources using search
In MATLAB Online, you can now use the Search box in the top-right corner of the desktop to easily
access toolstrip actions, preferences, and Help Center resources such as functions, blocks, examples,
and answers. To navigate to the Search box using a keyboard, press Ctrl+Shift+Space (or
Command+Shift+Space on macOS systems).

For example, to restore the MATLAB desktop to its default layout, enter the word layout in the
Search box. In the list of results, select the Layout - Two Column (Default) toolstrip action.

3-3
R2022b

3-4
Environment

System Theme in MATLAB Online: Change colors of MATLAB desktop


to match operating system color scheme
Windows and macOS systems support light and dark color schemes. Starting in R2022b, MATLAB
Online is configured to match the current operating system color scheme by default using the system
theme. If the selected color scheme for the operating system changes, the colors of the MATLAB
desktop change to match the new scheme.

To change the selected theme, on the Home tab, in the Environment section, click Preferences.
Select MATLAB > Appearance and select a theme from the Theme field. For more information, see
Change Desktop Colors.

If you customize the colors of the MATLAB desktop and then the MATLAB desktop theme changes to
a new theme or to match a change to the operating system color scheme, your customizations will be
lost. To avoid unexpectedly losing color customizations when the operating system color scheme
changes, select the Light or Dark option from the Theme field before making any color
customizations.

Help Center: View documentation for all products and determine


which products are installed
When viewing the documentation from an installed version of MATLAB, you can now view the
documentation for all products. Previously, you could view only the documentation for installed
products. The Help browser indicates installed products using a green bar to the left of the product
name or its category.

To view the list of installed products, select Product List at the top left of the Help browser. The
Help browser displays the list of products that are installed for the current version of MATLAB. If
MATLAB is configured to display the web documentation (default), the Help browser also displays the
list of products that are not installed.

3-5
R2022b

unsetenv Function: Remove environment variable


You can remove an environment variable from the operating system by using the unsetenv function.

isenv Function: Determine if environment variable exists


To determine if an environment variable exists in the operating system, you can use the isenv
function.

Comparison Tool: Compare MAT files, FIG files, live scripts, and live
functions in MATLAB Online
Starting in R2022b, you can compare MAT and FIG files in MATLAB Online. You also can compare live
scripts and functions.

You can access the comparison tool from:

• The MATLAB Current Folder browser context menu


• The Current Project browser context menu
• The MATLAB Command Window by using the visdiff function

Functionality being removed or changed


matlab.keyboard.ShowAutomatically and
matlab.commandwindow.ShowCompletionsAutomatically settings have been removed
Errors

The matlab.keyboard.ShowAutomatically and


matlab.commandwindow.ShowCompletionsAutomatically settings have been removed. Use the
matlab.editor.suggestions.ShowAutomatically and
matlab.commandwindow.suggestions.ShowAutomatically settings instead.

3-6
Environment

To update your code, change instances of the setting matlab.keyboard.ShowAutomatically to


matlab.editor.suggestions.ShowAutomatically and instances of the setting
matlab.commandwindow.ShowCompletionsAutomatically to
matlab.commandwindow.suggestions.ShowAutomatically. For more information, see
matlab.editor and matlab.commandwindow.

lookfor function no longer searches third-party and user-authored help text


Behavior change

The lookfor function no longer searches help text in third-party and user-authored MATLAB
program files. In previous releases, lookfor searches all MATLAB program files on the path,
including third-party and user-authored program files.

To search the documentation including third-party and custom documentation, use the docsearch
function instead. Alternatively, you can use the find features in the Current Folder browser. For
example, you can look for all occurrences of a specified word in all the MATLAB program files in the
current folder and its subfolders. For more information, see Find Files and Folders.

3-7
R2022b

Language and Programming

dictionary Object: Map unique keys to values for fast lookup


Dictionaries are useful for fast lookup of values in a large data set. A dictionary stores data as values,
which can be accessed using corresponding unique keys. For example, create a dictionary that
contains three key-value pairs.

d =

dictionary (string ⟼ double) with 3 entries:

"Unicycle" ⟼ 1
"Bicycle" ⟼ 2
"Tricyle" ⟼ 3

Use a key to look up the corresponding value in a dictionary.

d("Bicycle")

ans =

In almost all use cases, dictionary performs faster than containers.Map. For more information,
see dictionary.

Output Argument Validation: Validate output arguments in functions


and class methods
You can now define output argument blocks for functions and class methods. Use many of the
available argument validation techniques on output arguments, including size and data type
restrictions as well as validation functions. Input validation checks that function users provide valid
inputs. Output validation helps function authors ensure that their functions return the expected types
of outputs. It also helps identify errors in the function definition that cause unexpected outputs.

For example, realPolyRoots is based on the roots function. The input argument block restricts
the degree of the input polynomial to a quadratic. The output arguments block only allows the
function to return results when the roots are real valued.

function r = realPolyRoots(p)
arguments (Input)
p (1,3)
end

arguments (Output)
r {mustBeReal}
end

r = roots(p);
end

Calling realPolyRoots on x2 – 1 (p = [1 0 -1]) returns roots 1 and –1, but calling the function
on x2 + 1 errors.

3-8
Language and Programming

realPolyRoots([1 0 1])

Invalid output 'r'. Value must be real.

Error in realPolyRoots (line 11)


end

For more information, see Function Argument Validation.

Code Analyzer App: Identify code issues


The MATLAB Code Analyzer is now available as an app. Use the Code Analyzer app to identify issues
in code and implement suggested fixes when possible.

codeIssues Object: Identify and store code issues from one or more
files
Create a codeIssues object to identify and store code issues found within specified files. When
displayed in the Command Window, the codeIssues object shows the location of identified issues in
the code.

Custom Compact Display: Live Editor, Variables editor, and Workspace


browser follow CustomCompactDisplayProvider implementations
Starting in R2022b, the Live Editor, the Variables editor in MATLAB Online, and the single-line Value
field in the Workspace browser in MATLAB Online follow rules for customized object display
implemented using the matlab.mixin.CustomCompactDisplayProvider class. For more
information on custom compact displays, see Custom Compact Display Interface.

Customized Dot Indexing: New methods handle parentheses-dot


combinations
The matlab.mixin.indexing.RedefinesDot class has two new concrete methods—
parenDotAssign and parenDotListLength—that handle built-in parentheses indexing
immediately followed by customized dot indexing, such as obj(idx).prop = val. The two methods
have default implementations that provide the expected behavior, but you can override them if
needed.

Functionality being removed or changed


isequal and isequaln return false when comparing empty arrays of the same size but of
different classes
Behavior change

Previously, isequal and isequaln returned true when comparing two or more empty object arrays
of the same size, regardless of the class of the objects. Starting in R2022b, both functions return false
when comparing empty object arrays of the same size but different classes.

Defining classes and packages: Using schema.m will not be supported in a future release
Still runs

3-9
R2022b

Support for classes and packages defined using schema.m files will be removed in a future release.
Replace existing schema-based classes with classes defined using the classdef keyword.

Multiple repeating arguments blocks throw an error on empty blocks


Behavior change

If a function contains multiple arguments blocks with the Repeating property, MATLAB now throws
an error regardless of if the blocks are empty or have declared repeating arguments. Previously,
MATLAB threw an error only if there was more than one repeating block with repeating arguments
specified.

Multiple repeating arguments validate individual elements of all repeating arrays together
Behavior change

If a function contains multiple arguments with the Repeating property, argument validation
functions that accept multiple inputs will now make element-wise comparisons. For example, this
function uses a validation function with multiple repeating arguments as inputs.

function MyFoo(x,y)
arguments(Repeating)
x
y {mustBeGreaterThan(x,y)}
end
end

The validation function mustBeGreaterThan(x,y), validates each single element of y against a


single corresponding element of x. Previously, mustBeGreaterThan(x,y) validated a single
element of y against the entire cell array of repeating values of x.

Dynamic Regular Expressions: Commands in replacement expressions now check only the
local workspace for variables
Behavior change

Commands in replacement expressions using the syntax ${cmd} will only check the local workspace
for variables. Caller and global workspaces will not be available to commands in replacement
expressions. This means that commands in replacement expressions now work in parfor loops.

3-10
Data Analysis

Data Analysis

Data Cleaner App: Clean data in table


The Data Cleaner app supports importing and cleaning data in a table. You can access a table in the
MATLAB workspace or import a table from a file. Previously, the app cleaned only timetable data.

You can open the Data Cleaner app from the MATLAB section of the apps gallery in the Apps tab.
Alternatively, enter dataCleaner in the MATLAB Command Window.

Data Cleaner App: View sparklines and summary statistics


The Data view in the Data Cleaner app displays sparklines and summary statistics to quickly visualize
and interpret the data in each table or timetable variable. Show more information related to specific
points by pointing to a sparkline.

stackedplot Function: Plot data from multiple tables or timetables


The stackedplot function can now plot variables from multiple input tables or timetables. In
previous releases, stackedplot can plot variables only from a single table or timetable.

For example, to plot data from the two sample timetables indoors and outdoors, load the two MAT-
files and then call stackedplot.

load indoors.mat
load outdoors.mat
stackedplot(indoors,outdoors)

If you specify multiple inputs, then they must be either all tables or all timetables.

To work with multiple inputs, stackedplot has new name-value arguments:

• CombineMatchingNames — If true, then plot variables from different inputs but with the same
names in the same y-axis. If false, then plot them in different y-axes.
• LegendLabels — If specified, then create a legend with the specified labels instead of the names
of the input tables or timetables.
• LegendVisible — If "on", then display the legend. If "off", then hide the legend.

3-11
R2022b

• LegendOrientation — If "horizontal", then display the legend horizontally. If "vertical",


then display the legend vertically.

detrend Function: Detrend tabular data


The detrend function can detrend data in a table or timetable.

When detrending table or timetable data, you can:

• Specify tabular variables to detrend by using the DataVariables name-value argument.


• Append or replace tabular variables with variables containing detrended data by using the
ReplaceValues name-value argument.
• Specify the sample points as a table variable by using the SamplePoints name-value argument.
SamplePoints is not supported when the input data is a timetable.

rmoutliers Function: Define outlier locations, and optionally return


outlier indicator, thresholds, and center value
When using the rmoutliers function, you can define the location of outliers in the input data with a
known outlier indicator. Define outlier locations, rather than using an outlier detection method, by
setting the OutlierLocations name-value argument to a logical array the same size as the input
data.

Regardless of whether the outliers are defined or detected, the rmoutliers function can return a
logical outlier indicator array indicating the locations of outliers in the input data.

rmoutliers can also return the lower threshold value, upper threshold value, and center value used
by the outlier detection method. The code generated by the Clean Outlier Data task in the Live
Editor includes the new output arguments.

mape and rmse Functions: Calculate error between forecast and


actual data
Calculate the mean absolute percentage error and the root-mean-square error between arrays by
using the mape and rmse functions, respectively. You can specify the dimensions to operate along,
whether to include or omit zero values (mape only) or NaN values from the calculation, or a weighting
scheme.

isuniform Function: Determine if vector is uniformly spaced


Determine if a numeric vector is uniformly spaced up to round-off tolerance by using the isuniform
function. You can optionally return the step size between consecutive elements.

Serial date numbers and date strings are not recommended


To represent dates and times in MATLAB, use the datetime, duration, and calendarDuration
data types. The datetime data type represents points in time, and the duration and
calendarDuration data types represent lengths of time. In particular, the datetime data type
provides flexible date and time formats, storage out to nanosecond precision, and properties to
account for time zones and daylight saving time.

3-12
Data Analysis

Compatibility Considerations
Serial date numbers and date strings are not recommended. As a consequence, MATLAB functions
that create or modify serial date numbers or date strings, such the datenum and datestr functions,
are not recommended.

• For more information on MATLAB date and time functions that are no longer recommended, see
Functionality being removed or changed on page 3-16.
• For more information on replacing these functions in your code, see Replace Discouraged
Instances of Serial Date Numbers and Date Strings.

MATLAB functions that accept serial date numbers or date strings as inputs also accept datetime
arrays as inputs.

There are no plans to remove support for serial date numbers or date strings.

datetime and convertTo Functions: Convert between CDF TT2000


times and datetime arrays
The NASA Common Data Format (CDF) defines the CDF_TIME_TT2000 (or TT2000 for short) data
type as a high-resolution time type that handles leap seconds for data in CDF files. TT2000 times
represent the number of nanoseconds that have elapsed since J2000.

You can convert int64 arrays that represent TT2000 times to datetime arrays. To convert TT2000
times, call the datetime function with ConvertFrom set to "tt2000" and TimeZone set to
"UTCLeapSeconds". To account for leap seconds, you must specify the time zone of the output
datetime array.

X = int64([702077514184000000; ...
702163914184000000; ...
702250314184000000])
D = datetime(X,"ConvertFrom","tt2000","TimeZone","UTCLeapSeconds")

Also, you can convert datetime arrays to int64 arrays that represent TT2000 times. To convert
datetime arrays, call the convertTo function using the "tt2000" option. To account for leap
seconds, the input datetime array must have its time zone set to "UTCLeapSeconds".

D = datetime(2022,4,1:3,9,30,45, ...
"TimeZone","UTCLeapSeconds")
X = convertTo(D,"tt2000")

Data Preprocessing Live Editor Tasks: Plot multiple table variables


These Live Editor tasks can plot multiple table variables:

• Clean Missing Data


• Clean Outlier Data
• Find Change Points
• Find Local Extrema
• Normalize Data
• Smooth Data

3-13
R2022b

• Remove Trends

For table or timetable data, to visualize all selected table variables at once in a tiled chart layout, set
the Variable to display field.

Data Preprocessing Live Editor Tasks: Append cleaned table variables


and specify logical tabular output
These Live Editor tasks can append cleaned table variables to the input table variables:

• Clean Missing Data


• Clean Outlier Data
• Normalize Data
• Smooth Data
• Remove Trends

Additionally, in these Live Editor tasks, you can specify to output a table with logical variables:

• Find Change Points


• Find Local Extrema

To append cleaned table variables or specify a tabular output with logical variables, set the Output
format field.

Clean Missing Data Live Editor Task: Plot nonnumeric table data,
specify minimum number of missing entries, and use custom fill
method
The Clean Missing Data task in the Live Editor can now plot nonnumeric data. To display a
categorical histogram, select a nonnumeric input array or set the Variable to display field to a
nonnumeric table variable containing categorical, string, cellstr, calendarDuration, or
char data types.

You can specify a minimum number of missing entries required to remove a row of data. First, select
the Remove missing cleaning method, and then specify the minimum number of missing entries by
using the Min missing for removal field.

You can also specify a custom fill method for filling missing data. Select the Fill missing cleaning
method, and then specify a custom fill method by selecting the Custom function cleaning method
parameter and the local function or function handle option.

Clean Outlier Data Live Editor Task: Convert outliers to missing


Use the Clean Outlier Data task in the Live Editor to convert outlier data to missing data indicated
by the value NaN. Convert outlier data to missing data by setting the Cleaning method field to Fill
outliers and selecting the Convert to missing option.

3-14
Data Analysis

Live Editor and Variables Editor: Control placement of missing values


when sorting numeric data in MATLAB Online
In the Live Editor output and Variables editor in MATLAB Online, you can control the placement of
missing values (NaN, NaT, <undefined>, and missing) when sorting rows of numeric data.

For example, to place missing elements first, on the Home tab, in the Environment section, click
Preferences. Select MATLAB > Variables and set Placement of missing values to first.

In the Variables editor, you can also control missing value placement using the Variable tab. In the
Transform section, from the Sort list, select an option for Missing Placement.

Variables Editor: View sparklines and summary statistics for tabular


data in MATLAB Online
The Variables editor in MATLAB Online now displays sparklines and summary statistics to quickly
visualize and interpret the data in each table or timetable variable. Show more information related to
specific points by pointing to a sparkline. Show or hide the sparklines or summary statistics using the
Display section in the View tab.

Variables Editor: Navigate variable with Find and Go To dialog boxes


in MATLAB Online
In the Variables editor in MATLAB Online, search for any text in the current variable or selection. On
the Variable tab, in the Navigate section, click Find. You can also use the Ctrl+F keyboard shortcut.
In the Find dialog box, enter the text that you want to search for and use the arrow buttons to search

3-15
R2022b

backward or forward through the current variable. You can also change how the Variables editor
searches for text by selecting the match case, whole word, or regular expression search options.

Additionally, in the Variables editor in MATLAB Online, navigate to a particular location in the current
variable. On the Variable tab, in the Navigate section, click Go To. You can also use the Ctrl+G
keyboard shortcut. In the Go To dialog box, specify with numeric or text indices the row and column
that you want to navigate to.

Variables Editor: Interactively save logical indices of data selection in


MATLAB Online
In the Variables editor in MATLAB Online, create a new logical variable indicating the indices of the
selected data by right-clicking the selection or by clicking New from Selection in the Variable tab.

For tabular data:

• Append a logical table variable indicating the selection


• Create a logical column vector in the workspace indicating the selected rows
• Create a logical row vector in the workspace indicating the selected columns

For all other data types except for structure arrays and objects:

• Create a logical matrix in the workspace indicating the selection


• Create a logical column vector in the workspace indicating the selected rows
• Create a logical row vector in the workspace indicating the selected columns

Variables Editor: Replace tabular data with empty arrays in MATLAB


Online
In the Variables editor in MATLAB Online, replace the current selection of table or timetable elements
with empty 0-by-0 arrays by pressing the Delete key or by right-clicking the selection and selecting
Replace with Empty. The class of an empty array is determined by the class of the table variable.

Previously, you could interactively replace the current data selection with empty arrays for
nontabular data only.

Functionality being removed or changed


Character arrays have no standard missing value
Behavior change

For these functions, character arrays have no default definition of a standard missing value:

• ismissing
• rmmissing
• fillmissing
• standardizeMissing
• mustBeNonmissing

3-16
Data Analysis

• anymissing
• nummissing method of groupsummary

Blank char elements (' ') are treated as nonmissing. For example, ismissing(['a'; ' '])
returns logical array [0; 0]. In previous releases, it returns [0; 1].

To treat blank character array elements as missing, use an indicator. For example,
ismissing(['a'; ' '],' ') specifies a blank char as a missing value and returns [0; 1].

Join Tables Live Editor task automatically selects merging variables based on scoring
algorithm
Behavior change

If the Join Tables Live Editor task fails to automatically select the first pair of merging variables
based on row labels or variable names, then it tries to select them based on a scoring algorithm. The
Join Tables task selects and tests candidate pairs of merging variables using these steps:

1 Select row names (in a table) or row times (in a timetable) as the first pair of merging variables.
2 If step 1 fails, then select variables with names that exactly match as the first pair.
3 If steps 1 and 2 fail, then score pairs of variables using the scoring algorithm. Select the pair of
variables with the highest score as the first pair of merging variables.
4 If all previous steps fail, then select the first items in the Merging variable drop-down lists as
the first pair of merging variables.

In previous releases, step 3 was to select the pair of variables whose names gave the best partial
match as the first pair of merging variables.

Java objects open in an improved Property Inspector


Behavior change

Java objects now open in an improved Property Inspector that is consistent with the one used for
graphics and other handle objects. For example, view and edit the properties of a Java object using
the improved Property Inspector.

myDate = java.util.Date;
inspect(myDate)

3-17
R2022b

Calling head and tail functions without specified output arguments does not store output in
ans
Behavior change

When you call the head and tail functions without specified output arguments, they display the
selected rows of input tables, but they do not store output in the ans variable. In previous releases,
calling head and tail without specified output arguments causes output to be stored in ans.

Calling head and tail in a live script is usually not recommended. Instead, display the table or
timetable by typing the variable name with no semicolon. The Live Editor provides a widget that
enables you to examine the entire table or timetable. However, if you do call head or tail in a live
script, you should assign the output to a variable so that the live script creates a widget for the
output.

addtodate function is not recommended


Still runs

There are no plans to remove addtodate. However, the datetime, duration, and
calendarDuration data types are recommended instead. The datetime data type provides flexible
date and time formats, storage out to nanosecond precision, and properties to account for time zones
and daylight saving time. You can add lengths of time to datetime values by using duration values
(for hours, minutes, and seconds) or calendarDuration values (for calendar years, quarters,
months, weeks, or days).

For example, convert a serial date number to a datetime value. Then add an array of hours, in 4-
hour increments, by using the hours function to create an array of duration values. The result is an
array of datetime values.

d = 738522;
d = datetime(d,"ConvertFrom","datenum")

3-18
Data Analysis

d = datetime
01-Jan-2022

d = d + hours(0:4:12)

d = 1x4 datetime array


01-Jan-2022 00:00:00 01-Jan-2022 04:00:00 01-Jan-2022 08:00:00 01-Jan-2022 12:00:00

Add 3 calendar months and 2 calendar weeks to a datetime value that represents January 1, 2022,
12:00 p.m. by using the calmonths and calweeks functions to create calendarDuration values.
The result is a datetime value that represents April 15, 2022, 12:00 p.m.

d = datetime("01-Jan-2022 12:00:00");
d = d + calmonths(3) + calweeks(2)

d = datetime
15-Apr-2022 12:00:00

clock function is not recommended


Still runs

There are no plans to remove clock. However, the datetime function is recommended instead. The
datetime data type provides flexible date and time formats, storage out to nanosecond precision,
and properties to account for time zones and daylight saving time.

To return the current time as a datetime value, call datetime with "now" as the input argument.

d = datetime("now")

d = datetime
15-Apr-2022 15:53:28

date function is not recommended


Still runs

There are no plans to remove date. However, the datetime function is recommended instead. The
datetime data type provides flexible date and time formats, storage out to nanosecond precision,
and properties to account for time zones and daylight saving time.

To return the current date as a datetime value, call datetime with "today" as the input argument.

d = datetime("today")

d = datetime
15-Apr-2022

datenum function is not recommended


Still runs

There are no plans to remove datenum. However, the datetime, duration, and
calendarDuration data types are recommended instead. The datetime data type provides flexible
date and time formats, storage out to nanosecond precision, and properties to account for time zones
and daylight saving time. MATLAB functions that accept serial date numbers as inputs also accept
datetime arrays as inputs.

To convert a serial date number to a datetime value, call datetime with the ConvertFrom name-
value argument set to "datenum".

3-19
R2022b

d = 738522;
d = datetime(d,"ConvertFrom","datenum")

d = datetime
01-Jan-2022

datestr function is not recommended


Still runs

There are no plans to remove datestr. However, the string and char functions are recommended
instead for converting datetime arrays to text. The datetime data type provides flexible date and
time formats, storage out to nanosecond precision, and properties to account for time zones and
daylight saving time.

For example, represent the current date and time as a datetime value. Then convert it to a string.
d = datetime("now")

d = datetime
15-Apr-2022 15:53:28

str = string(d)

str =
"15-Apr-2022 15:53:28"

Using datevec function on serial date numbers is not recommended


Still runs

Using datevec with serial date numbers as inputs is not recommended. Use the datetime data type
to represent points in time instead. The datetime data type provides flexible date and time formats,
storage out to nanosecond precision, and properties to account for time zones and daylight saving
time.

To split datetime values into date and time components, use the hms, ymd, or datevec functions, or
use the Year, Month, Day, Hour, Minute, and Second properties of datetime values.

For example, call datevec on a datetime value that represents the current date and time.
d = datetime("now")

d = datetime
15-Apr-2022 15:53:28

format shortg
dateVector = datevec(d)

dateVector =

2022 4 15 15 53 28

To access one component, use the corresponding datetime property. For example, get the value of
the Month property of d.
monthValue = d.Month

monthValue =

3-20
Data Analysis

etime function is not recommended


Still runs

There are no plans to remove etime. However, the datetime, duration, and calendarDuration
data types are recommended instead. The datetime data type provides flexible date and time
formats, storage out to nanosecond precision, and properties to account for time zones and daylight
saving time.

To calculate the elapsed time between two datetime values, either subtract one from the other or
use the between function. For example, subtract the start of today from the current date and time.
Return the elapsed time as a duration value.

startOfToday = datetime("today")
currentTime = datetime("now")

startOfToday = datetime
15-Apr-2022

currentTime = datetime
15-Apr-2022 15:53:28

elapsedTime = currentTime - startOfToday

elapsedTime = duration
15:53:28

To return elapsed time as a calendarDuration value, use between.

d1 = datetime("2022-01-01")
d2 = datetime("now")
elapsedTime = between(d1,d2)

elapsedTime = calendarDuration
6mo 18d 13h 19m 18.5561949999974s

now function is not recommended


Still runs

There are no plans to remove now. However, the datetime function is recommended instead. The
datetime data type provides flexible date and time formats, storage out to nanosecond precision,
and properties to account for time zones and daylight saving time.

To return the current date and time as a datetime value, call datetime. You can call it without any
input arguments, or with "now" as the input argument.

d = datetime
% or
d = datetime("now")

d = datetime
15-Apr-2022 15:53:28

3-21
R2022b

Data Import and Export

Parquet: Use Parquet files containing nested structured data


Write nested table and timetable variables to Parquet files using parquetwrite. Read nested data
from Parquet files as nested tables using parquetread and parquetDatastore.

SequentialDatastore Object: Sequentially read data from multiple


datastores
Sequentially read data from multiple underlying datastores without concatenation using a
SequentialDatastore object. Create a SequentialDatastore object using the combine
function with the ReadOrder name-value argument.

Datastores: Create subsets of arbitrarily nested transformations and


combinations of datastores
Create subsets of data from TransformedDatastore, CombinedDatastore, and
SequentialDatastore objects using the subset function. You can subset these datastore objects
only if their underlying datastores are subsettable (able to be subset). The underlying datastores can
also be transformations or combinations of datastores that are subsettable.

Test whether you can create subsets of these datastore objects using the isSubsettable function.
isSubsettable returns true when the underlying datastore can be subset.

Parallel Processing: Use low-level file I/O operations in thread-based


environments
Use low-level file operations, such as fread, in thread-based environments. Parallel processing
results in improved performance when reading data, especially with remote data. For a list of low-
level functions that support thread-based environments, see Low-level File I/O.

CDF Interface: Read CDF_INT8 and CDF_TIME_TT2000 data


You can now use cdfinfo, cdfread, and the low-level CDF package functions to display and read
CDF_INT8 and CDF_TIME_TT2000 variables and attributes from CDF datasets.

• High-level interface — cdfread reads CDF_TIME_TT2000 data as datetime values by default. To


read the data as int64 values, use the new name-value argument DatetimeType.
• Low-level interface — CDF_TIME_TT2000 data is read as int64 values.

Use these two new functions to convert to and from CDF_TIME_TT2000 int64 timestamps:

• cdflib.computeTT2000 — Calculate a CDF_TIME_TT2000 int64 timestamp from an input


vector of UTC-based date and time components.
• cdflib.breakdownTT2000 — Decompose a CDF_TIME_TT2000 int64 timestamp into an output
vector of UTC-based date and time components.

3-22
Data Import and Export

imwrite Function: Use datetime values to write metadata for PNG


images
You can write PNG image metadata using datetime values by specifying the CreationTime and
ImageModTime name-value arguments with the imwrite function.

Image File Format Libraries: LibTIFF library upgraded to version 4.4.0


The LibTIFF library is upgraded to version 4.4.0.

Scientific File Format Libraries: HDF4 and HDF-EOS2 libraries are


upgraded
The HDF4 library is upgraded to version 4.2.15, and the HDF-EOS2 library is upgraded to version
3.0.

Functionality being removed or changed


NetCDF Interface: Use Fletcher32 checksum filter only with fixed-length data types
Behavior change

The Fletcher32 checksum filter can be used only with fixed-length data types and generates an
error if you apply it to variables of type NC_STRING or NC_VLEN. Previously, if you applied the
Fletcher32 filter to datasets that included NC_STRING or NC_VLEN data, the filter was silently
ignored.

Use system web browser when opening links to external sites (recommended) preference
has been removed
Behavior change

The Use system web browser when opening links to external sites (recommended) preference
has been removed. Open all external sites using your system web browser.

Previously, you could use this preference to specify whether to open external sites using the system
web browser or the MATLAB web browser.

3-23
R2022b

Mathematics

pagenorm Function: Calculate norms using pages of N-D arrays


Use the pagenorm function to calculate vector and matrix norms of the pages of N-D arrays. In this
context, the N-D array is treated as a container for several 2-D matrices. This function is particularly
useful for calculating error metrics for the outputs of other page-wise functions, such as pagesvd
and pagemldivide.

Functionality being removed or changed


"0" syntaxes of qr, gsvd, and svd are not recommended for economy-size decompositions
Still runs

These qr, gsvd, and svd syntaxes for performing economy-size decompositions are no longer
recommended:

• [___] = qr(A,0) and [___] = qr(S,B,0)


• [U,V,X,C,S] = gsvd(A,B,0)
• [___] = svd(A,0)

There are no plans to remove support for the "0" syntax. However, using the "econ" option to
perform economy-size decompositions with these functions is recommended instead.

gsvd output sizes are based on numerical rank of [A; B]


Behavior change

With the function call [U,V,X,C,S] = gsvd(A,B), where A is m-by-p and B is n-by-p, the gsvd
function returns:

• X as p-by-q
• C as m-by-q
• S as n-by-q

Additionally, with one output argument, the function call sigma = gsvd(A,B) returns a vector of
the generalized singular values with length q.

The behavior change is that in all of these cases q is now equal to the numerical rank of [A; B]. The
numerical rank is calculated from the QR factorization of [A; B]. This change ensures that nonzero
elements of C and S are uniquely determined.

Previously, the value of q was min(m+n,p), and gsvd returned extra columns (or elements) in the
outputs when [A; B] was not full rank.

3-24
Graphics

Graphics

Plotting Table Data: Create stem, stairstep, and geographic plots by


passing tables directly to plotting functions
Create plots by passing a table directly to any of these functions: stem, stem3, stairs, geoplot,
and geoscatter. If you create any of these plots with a table and then add a legend, the legend
items are automatically labeled with the table variable names. If you create a stem or stairstep plot,
the axis labels are automatically set to the corresponding variable names (geographic plots always
have "Longitude" and "Latitude" axis labels regardless of the variable names).

For example, create a table with the variables Estimate and Measurement. Pass the table to the
stem function as the first argument, and specify the variables you want to plot.

Estimate = (1:13)';
Measurement = (1:13)';
T = table(Estimate,Measurement);
stem(T,"Estimate","Measurement")

errorbar Function: Plot multiple lines with error bars at once


The errorbar function now accepts the same combinations of matrices and vectors as the plot
function does. As a result, you can plot multiple lines at once rather than calling the hold function
between plotting commands.

3-25
R2022b

tightPosition Function: Get the location and size of axes plotting area
Call the tightPosition function to get the location and size of the plotting area of the axes. This
function is useful for aligning objects in the figure with the plotting area, particularly when you are
working with polar axes, axes that display images, or other visualizations that have nondefault aspect
ratios.

tilenum and tilerowcol Functions: Convert between rows and columns


and tile numbers in tiled chart layouts
When working with tiled chart layouts, you can find the tile number for a specific row and column by
calling the tilenum function. To find the row and column numbers that correspond to a specific tile
number, use the tilerowcol function. You can also use these functions to locate the objects within
the layout.

Tiled Chart Layout: Define GridSizeChangedFcn callback that executes


when the grid size changes
Define the GridSizeChangedFcn callback function on a tiled chart layout. The callback function
executes when the GridSize property of the layout changes. This callback is primarily useful for
layouts that use the "flow" tile arrangement. For example, you can define a callback that displays
the x-axis tick labels only in the bottom row of axes.

Contour Plots: Customize contour labels, colors, and transparency


Customize the appearance of a contour plot by setting these properties of the Contour object:

3-26
Graphics

• LabelFormat — Specify the formatting of the contour labels as a format operator that the
compose function accepts. You can also specify a handle to a function that performs calculations
when formatting the labels.
• FaceColor and EdgeColor — Specify the fill color between contour lines with the FaceColor
property, and specify the colors of the contour lines with the EdgeColor property. These new
properties replace the Fill and LineColor properties from previous releases.
• FaceAlpha and EdgeAlpha — Specify the transparency of the colors between contour lines with
the FaceAlpha property, and specify the transparency of the contour lines with the EdgeAlpha
property.

boxchart Function: Specify the box edge color and box median line
color
The boxchart function now includes options for the box edge color and box median line color. You
can specify these colors using the BoxEdgeColor and BoxMedianLineColor name-value
arguments, respectively.

3-27
R2022b

3-D Stem and Bar Plots: Expanded data type support


The stem3, bar3, and bar3h functions now support more data types. The available data types
depend on the specific arguments.

These arguments can be any numeric values as well as datetime, duration, and categorical values:

• stem3: x, y, and z (stem x and y positions and corresponding z-values)


• bar3: y (bar positions along the y-axis)
• bar3h: z (bar positions along the z-axis)

These arguments can be any numeric values and duration values:

• bar3: z (bar heights)


• bar3h: y (bar lengths)

Image Objects: Control the maximum resolution for displaying images


Control the maximum displayed resolution along the larger dimension of an image by setting the
MaxRenderedResolution property when calling image or imagesc. The value affects the on-
screen display, but it does not affect the image data, which is stored in the CData property of the
image.

Figure Code: Generate code for figure formatting in MATLAB Online


When you edit graphics object properties for a figure in MATLAB Online using the Format tab,
MATLAB generates code for the figure formatting. On the Figure tab, click the Format button to
open the Format tab. Use the options in the Format tab to interactively customize properties. Then,
to view, copy, or export the generated code, select Show Code in the File section of the Figure tab.

Previously, code was not generated when editing properties using the Format tab. MATLAB does not
generate code when editing properties using the Property Inspector.

3-28
Graphics

Plot Options: Customize figure creation, data linking, and labeling in


MATLAB Online
In the Variables editor in MATLAB Online, use Plot Options in the Variable tab to customize plots
and generate corresponding code in the command window. You can create a figure, link numeric data
with supported charts, and generate titles, legends, and labels.

In addition, you can brush numeric data in a linked plot and create a new logical variable from
selected indices. Create the logical variable by right-clicking the selection in the Variables editor or
by clicking New from Selection in the Variable tab.

Functionality being removed or changed


Legends update when you delete lines or other plot objects
Behavior change

If you delete an object from the axes, such as a Line or Scatter object, the legend updates to
reflect the change regardless of whether the AutoUpdate property is set to "on" or "off".

Previously, the legend did not update when you removed objects from the axes while the AutoUpdate
property was set to "off".

Plots created with tables preserve special characters in axis and legend labels
Behavior change

When you pass a table and one or more variable names to a plotting function, the axis and legend
labels now display any special characters that are included in the table variable names, such as
underscores. Previously, special characters were interpreted as TeX or LaTeX characters.

For example, this code creates a line plot from a table that has underscores in the variable names. In
R2022b, the underscores appear in the x-axis label and the legend labels. In R2022a and earlier
releases, the underscores are interpreted as subscripts.

Sample_Number = (0:10)';
Mean_AM = (2:12)';
Mean_PM = (3:13)';
t = table(Sample_Number,Mean_AM,Mean_PM);
plot(t,"Sample_Number",["Mean_AM" "Mean_PM"])
legend

3-29
R2022b

To display axis and legend labels with TeX or LaTeX formatting, specify the labels manually. In this
case, call the xlabel and legend functions with the desired label strings.

xlabel("Sample_Number")
legend(["Mean_AM" "Mean_PM"])

Adding new plots to geographic axes does not reset basemap


Behavior change

When you plot into geographic axes by using functions such as geoplot and geoscatter, MATLAB
does not reset the basemap. In R2022a and earlier releases, the basemap resets when you add new
plots.

As a result, you can specify a basemap and then visualize data without using the hold function
between commands. For example, this code creates a map using the streets basemap. Then it
displays a scatter plot over the basemap. In R2022b, the basemap does not reset. In R2022a and
earlier releases, the basemap resets to the default streets-light.

lat = [35 -22 51 39 37 42 47 -33];


lon = [139 -43 0 116 23 -71 -122 18];

figure
geobasemap streets
geoscatter(lat,lon,"filled")

3-30
Graphics

This change does not affect existing code that sets the hold state to "on" between commands.

To reset the basemap when you add a new plot, use the cla reset syntax of the cla function before
you create the plot. For example, to update the preceding code, use cla reset between the calls to
geobasemap and geoscatter.

lat = [35 -22 51 39 37 42 47 -33];


lon = [139 -43 0 116 23 -71 -122 18];

figure
geobasemap streets
cla reset
geoscatter(lat,lon,"filled")

Alternatively, you can change the basemap to the default streets-light by using the geobasemap
function. For more information about changing the basemap of geographic axes, see Access
Basemaps for Geographic Axes and Charts.

errorbar returns error for 3-D and higher dimensional data arrays
Behavior change

The errorbar function now returns an error when you specify 3-D or higher dimensional arrays for
the x-coordinates, y-coordinates, or the error bar lengths. Previously, errorbar plotted the data from
the first two dimensions and silently ignored the data in the higher dimensions.

Fill and LineColor properties of Contour objects are not recommended


Still runs

Setting or getting the value of the Fill property or the LineColor property of a Contour object is
not recommended. Use the FaceColor and EdgeColor properties instead. The FaceColor property
provides more options for specifying colors than the Fill property does, and the EdgeColor
property provides the same options as the LineColor property does.

This table shows typical usages of the Fill and LineColor properties and how to update your code
to use the FaceColor and EdgeColor properties instead.

3-31
R2022b

Not Recommended Recommended


contour(peaks,"Fill",true) contour(peaks,"FaceColor","flat")
contour(peaks,"LineColor",[0 0 0]) contour(peaks,"EdgeColor",[0 0 0])

There are no plans to remove the Fill or LineColor properties, but they are no longer listed when
you call the set, get, or properties functions on the Contour object.

Some printing and exporting workflows will no longer support UI components


Still runs

These functions and menu items will no longer support printing or exporting UI components in a
future release:

• The print function


• The saveas function
• The hgexport function
• The File > Save As menu item on the figure
• The File > Export Setup menu item on the figure
• The Edit > Copy Options menu item on the figure

To export a figure containing UI components, call the exportapp function. For example, create a
simple app containing two buttons and a slider. Export the contents of the figure as a PDF file by
calling the exportapp function.

% Create figure with three UI components


f = uifigure;
button1 = uibutton(f,"Position",[150 300 100 50]);
button2 = uibutton(f,"Position",[300 300 100 50]);
slider1 = uislider(f,"Position",[150 250 250 3]);

% Export the contents of the figure


exportapp(f,"myapp.pdf")

Alternatively, call the getframe function to capture the contents of the figure. Then call the imwrite
function to save the content. This time, save the content as a JPEG file.

F = getframe(f);
imwrite(F.cdata,"myapp.jpg");

Exporting workflows will no longer support BMP, HDF, PBM, PCX, PGM, and PPM files
Still runs

These functions and menu items will no longer support BMP, HDF, PBM, PCX, PGM, and PPM files in
a future release:

• The print function


• The saveas function
• The hgexport function
• The File > Save As menu item on the figure
• The File > Export Setup menu item on the figure

3-32
Graphics

To export graphics using one of these formats, use the imwrite function instead. For example, create
a line plot, and capture the contents of the current figure using the getframe function. Then save
the content as a BMP file.

plot([0 3 2 4 1]);
F = getframe(gcf);
imwrite(F.cdata,"myplot.bmp");

Some exporting workflows will no longer support PostScript (.ps) files


Still runs

These functions and menu items will no longer support creating full-page PostScript (.ps) files in a
future release:

• The print function


• The saveas function
• The hgexport function
• The File > Save As menu item on the figure
• The File > Export Setup menu item on the figure

To export graphics files, call the exportgraphics function. Specify an .eps, .pdf, or .emf file
extension and set the ContentType option to "vector". This function captures content that is
tightly cropped around plots, and it does not create full-page output. For example, create a plot and
save the contents of the current figure as a PDF file containing vector graphics.

plot([0 3 2 4 1]);
exportgraphics(gcf,"myplot.pdf","ContentType","vector")

Alternatively, call the print function and specify an .eps, .emf, or .svg file extension. For example,
create a plot and save the contents of the current figure as an EPS file.

plot([0 3 2 4 1]);
print("myplot.eps","-depsc")

The getframe function will no longer capture the figure toolbar, menu bar, or borders
Still runs

In a future release, the getframe function will no longer support capturing the figure toolbar, menu
bar, or the border around the figure using the rect argument. You will still be able to define a
subsection of the figure to capture, but the toolbar, menu bar, and borders will not be included.

As an alternative, you can use the exportapp function to capture the toolbar and menu bar, but not
the borders.

The printopt function will be removed


Still runs

The printopt function will be removed in a future release. To configure printer defaults, use the
options provided by your operating system.

3-33
R2022b

App Building

ClickedFcn and DoubleClickedFcn Callbacks: Program a response to a


user clicking or double-clicking a tree, check box tree, list box, table,
or drop-down component
Program a response to a user clicking and double-clicking a UI component by using the ClickedFcn
and DoubleClickedFcn callback properties. You can specify both of these callbacks for tree, check
box tree, list box, and table UI components in App Designer and apps created using the uifigure
function. You can also specify the ClickedFcn callback for drop-down components.

For more information, see the UI component properties pages:

• Tree Properties
• CheckBoxTree Properties
• ListBox Properties
• Table Properties
• DropDown Properties

uieditfield Function: Specify valid length and input type for edit field
text
You can now specify the length and character type of valid input text for a text edit field created using
the uieditfield function.

• Use the CharacterLimits property to specify a maximum and minimum number of allowed
characters.
• Use the InputType property to restrict the allowed character types. Specify InputType as
"letters", "digits", "alphanumerics", or "text".

For more information, see EditField Properties.

uiimage Function: Create an image hyperlink


To open a web address when a user clicks an image in your app, specify the URL property of the
image component created using the uiimage function.

For more information, see Image Properties.

uipanel and uibuttongroup Functions: Specify container border width


In apps created using the uifigure function, use the BorderWidth property to change the border
width of panels and button groups created using the uipanel and uibuttongroup functions.

For more information, see Panel Properties and ButtonGroup Properties.

3-34
App Building

uigridlayout Function: Query grid layout manager size and location


Use the Position, InnerPosition, and OuterPosition properties of a grid layout manager
created using the uigridlayout function to access its size and location. These properties are read-
only.

For more information, see GridLayout Properties.

uibutton and uitogglebutton Functions: Specify additional icon and


icon alignment options
You can now use these additional options when adding an icon to a push button, state button, or
toggle button:

• Specify the Icon property as a predefined icon, such as "success".


• Specify the IconAlignment property as "leftmargin" or "rightmargin" to display the icon
on the far left or far right of the button, regardless of the button text location.

For more information, see Button Properties.

uitoolbar Function: Specify background color of toolbar


Specify the background color of a toolbar created using the uitoolbar function by using the
BackgroundColor property. You can modify this property only in App Designer and apps created
using the uifigure function.

For more information, see Toolbar Properties.

scroll Function: Programmatically scroll to specified component in


container
To programmatically scroll to a component in a container or button group with the scroll function,
use the syntax scroll(container,component).

isInScrollView Function: Determine if any component in a container is


visible, not only direct children
When you use the isInScrollView function to determine if a UI component is visible in a scrollable
container, that component can be any descendent of the scrollable container, not only a direct child.
For example, you can check whether a button in a panel is visible in a scrollable UI figure.

App Designer: Add and delete callbacks more efficiently


When you select multiple components in App Designer that have a callback type in common, you can
now create a single shared callback for all the selected components. For example, in an app with an
edit field and a slider, you can select the two components, right-click one of them, and select
Callbacks > Add ValueChangingFcn callback. App Designer creates a single new callback and
assigns it to both the edit field and the slider.

You can also now more easily find callbacks in your app that are not assigned to any components. In
Code View, navigate to the Callbacks tab in the Code Browser. An unassigned callback appears

3-35
R2022b

with a icon next to its name. If you do not need the callback, you can delete it by right-clicking

the callback name and selecting Delete.

App Designer: Move components between tabs


To move a component from one tab to another, in Design View, drag the component and pause on
the new tab. App Designer switches the selected tab to the new tab. You can then position the
component in the new tab.

Graphics Support: Restore axes view and display context menu for
interaction modes
In a figure created with the uifigure function or a figure in MATLAB Online, when an interaction
mode is enabled, you can double-click in the axes to restore the original axes limits and view. You can
also right-click to display a mode-based context menu.

For example, create a plot in a UI figure and enable the pan interaction mode.
fig = uifigure;
ax = axes(fig);
plot(ax,1:10)
pan(ax,"on");

Interactively pan the axes. Then, restore the original axes limits and view by double-clicking in the
axes. You can display a mode-based context menu by right-clicking in the axes.

Previously, these workflows were supported only for figures created with the figure function.

Graphics Support: Use visual camera toolbar interface


Syntaxes of cameratoolbar that make the visual toolbar interface visible are now supported by
figures created with the uifigure function. Previously, figures created with the uifigure function
supported only syntaxes of the cameratoolbar function that did not directly make the toolbar
visible. Now, the visual camera toolbar interface and all syntaxes are supported by figures and UI
figures.

Comparison Tool: Toggle the ability to navigate only mergeable


changes
When using the Comparison Tool to merge changes between two app files, you can now choose to

navigate only mergeable changes. To toggle this ability, while in merge mode, click Mergeable
Only in the toolstrip. If Mergeable Only is selected, when you navigate changes using the Previous
and Next buttons, the tool skips changes that are not mergeable, such as changes to the noneditable
code generated by App Designer. The Mergeable Only button is selected by default.

Functionality being removed or changed


InnerPosition property of tab group returns the position excluding borders and titles
Behavior change

3-36
App Building

For apps created in App Designer and using the uifigure function, when you query the
InnerPosition property of a tab group created using the uitabgroup, the property returns a
different value than in the previous release. In addition, if the TabLocation is 'left' or 'bottom',
when you query the Position, InnerPosition, and OuterPosition properties of a tab created
using the uitab function, the properties might return different values than in the previous release.

This table describes the differences in the property values between R2022b and previous releases.

Property Starting in R2022b R2022a and Earlier


Description Image Description Image
InnerPosition A four-element Tab group A four-element Tab group
of a tab group vector of the form InnerPosition vector of the form InnerPosition
[left bottom (blue solid line) [left bottom (blue solid line)
width height] width height]
that represents the that represents the
size and location of size and location of
the tab group the tab group
relative to the relative to the
drawable area of drawable area of
its parent, its parent,
excluding borders including borders
and titles of the and titles of the
tabs it contains tabs it contains

3-37
R2022b

Property Starting in R2022b R2022a and Earlier


Description Image Description Image
Position, A four-element Tab Position A four-element Tab Position
InnerPosition, vector of the form (orange dashed vector of the form (orange dashed
and [left bottom line) relative to tab [left bottom line) relative to tab
OuterPosition width height] group drawable width height] group drawable
of a tab that represents the area (blue solid that represents the area (blue solid
size and location of line) size and location of line)
the tab relative to the tab relative to
the tab group the tab group
drawable area, drawable area,
where the tab where the tab
group drawable group drawable
area excludes area includes
borders and titles borders and titles

If you notice changes in your app layout, consider updating your code in this way:

• Tab group InnerPosition — Replace references to the tab group InnerPosition property
with the tab group Position property to use the size and location of the tab group including the
borders and tab titles.
• Tab Position, InnerPosition, and OuterPosition — Replace references to the first two
elements of the position vector to instead use the space taken up on the left or bottom by the tab
titles. For example, if your app contains a tab group with a TabLocation value of 'left' and
you reference the Position property of a tab in that tab group, replace that reference with the
horizontal distance between the tab group border and the tab drawable area.

Table Extent property will return the default table UI component width and height
Behavior change in future release

In a future release, when you query the Extent property of a table UI component created using the
uitable function in a figure-based app, the property will always return [0 0 300 300]. The third
and fourth elements of the vector represent the default table width and height. Currently, querying
Extent returns a vector where the third and fourth elements represent the width and height of the
rectangle outlining the table area, estimated using the table data, row heights, and column widths. If
you use the Extent property to specify the position of UI components in your app, the table UI
component might have a different size or the layout of your app might appear shifted.

3-38
App Building

Consider updating your code to remove references to the table Extent property by using one of
these alternatives:

• Lay out the table and other UI components by manually specifying the Position property.
• Transition your figure-based app to use uifigure, and use a grid layout manager with a row
height or column width of 'fit' to automatically scale your app layout based on the size of the
table with its data. For more information, see Update figure -Based Apps to Use uifigure.

3-39
R2022b

Performance
prctile, quantile, and iqr Functions: Improved performance with small
input data
The prctile, quantile, and iqr functions show improved performance due to faster input parsing.
The performance improvement is most significant when input parsing is a greater portion of the
computation time. This situation occurs when:

• The size of the input data is small.


• The number of percentages or cumulative probabilities is small.
• Computation is along the default operating dimension.

For example, this code calculates four percentiles for a 3000-element matrix. The code is about 5x
faster than in the previous release.
function timingPrctile
A = rand(300,10);
for k = 1:3e3
P = prctile(A,[20 40 60 80]);
end
end

The approximate execution times are:

R2022a: 1.0 s

R2022b: 0.2 s

The code was timed on a Windows 10, Intel Xeon CPU E5-1650 v4 @ 3.60 GHz test system using the
timeit function.
timeit(@timingPrctile)

mldivide and pagemldivide Functions: Improved performance with


small matrices
The mldivide and pagemldivide functions show improved performance when solving linear
systems A*x = b with a small coefficient matrix A. The performance improvement applies to real
matrices that are 16-by-16 or smaller, and complex matrices that are 8-by-8 or smaller.

• Using mldivide, this code solves a linear system specified by a real 12-by-12 matrix. The code is
about 1.7x faster than in the previous release.
function mldividePerf
A = rand(12);
for k = 1:1e5
x = A\A;
end
end

The approximate execution times are:

R2022a: 0.72 s

3-40
Performance

R2022b: 0.42 s
• Using pagemldivide, this code solves three triangular linear systems specified by an 11-by-11-
by-3 array. The code is about 2.2x faster than in the previous release.

function pagemldividePerf
a = triu(rand(11));
A = cat(3,a,a,a);
for k = 1:1e5
x = pagemldivide(A,A);
end
end

The approximate execution times are:

R2022a: 0.65 s

R2022b: 0.30 s

In both cases, the code was timed on a Windows 10, Intel Xeon CPU W-2133 @ 3.60 GHz test system
using the timeit function:

timeit(@mldividePerf)
timeit(@pagemldividePerf)

conv, conv2, and convn Functions: Improved performance when


convolving two vectors, matrices, and arrays
The conv, conv2, and convn functions show improved performance when convolving two vectors,
matrices, and arrays for almost all input sizes.

• Using conv, this code convolves a 1,000,000-by-1 vector and a 10,000-by-1 vector. The code is
about 3x faster than in the previous release.

function timingTest
rng default;
u = randn(1000000,1);
v = randn(10000,1);
tic
w = conv(u,v);
toc
end

The approximate execution times are:

R2022a: 0.40 s

R2022b: 0.13 s
• Using conv2, this code convolves a 512-by-512 matrix and a 256-by-256 matrix. The code is about
4x faster than in the previous release.

function timingTest
rng default;
A = randn(512);
B = randn(256);
tic

3-41
R2022b

C = conv2(A,B);
toc
end

The approximate execution times are:

R2022a: 0.97 s

R2022b: 0.24 s
• Using convn, this code convolves a 128-by-64-by-32 array and a 64-by-32-by-16 array. The code is
about 4.9x faster than in the previous release.
function timingTest
rng default;
A = randn(128,64,32);
B = randn(64,32,16);
tic
C = convn(A,B);
toc
end

The approximate execution times are:

R2022a: 1.08 s

R2022b: 0.22 s

All of the code was timed on a Windows 10, Intel Xeon CPU E5-1650 v4 @ 3.60 GHz test system by
calling the timingTest function in each case.

Tall Arrays: Improved performance when indexing tall arrays backed


by parquetDatastore
Tall arrays backed by parquetDatastore show improved performance with row-indexing
operations. The performance improvement arises from the use of predicate pushdown to reduce the
amount of data that is imported into MATLAB. So, the improved performance is most noticeable with
data that has a large number of rows compared to the number of rows returned by the indexing
operation. The improvement gets better as the number of rows being filtered increases.

For example, this code creates a tall array backed by a Parquet datastore for the
airlinesmall.parquet file, and then performs row indexing to extract rows that meet several
specified conditions. The operation returns 10 rows out of 1.2 million and executes about 2.3x faster
than in the previous release.
function parquetPerf
mapreducer(0)
pds = parquetDatastore("airlinesmall.parquet");
pds.Files = repelem(pds.Files,10);
T = tall(pds);
conditions = T.DepDelay >= seconds(10) & T.DepDelay <= seconds(80) ...
& T.UniqueCarrier == "AA" ...
& T.DepTime >= datetime(2000,1,1) & T.DepTime < datetime(2000,1,7);

idx_rows = T(conditions,:);
g = gather(idx_rows);
end

3-42
Performance

The approximate execution times are:

R2022a: 8.0 s

R2022b: 3.5 s

The code was timed on a Windows 10, Intel Xeon CPU W-2133 @ 3.60 GHz test system using the
timeit function:
timeit(@parquetPerf)

App Building: Improved app startup performance


Apps created in App Designer and using the uifigure function start up faster in R2022b than in
R2022a. The improvement is more noticeable for apps with many UI components and apps that use a
grid layout manager. The startup performance is faster both the first time you run your app during a
MATLAB session and in subsequent times.

For example, this code creates an app with 1000 edit field components. The code is about 1.6x faster
than in the previous release.
function timingApp
fig = uifigure;
gl = uigridlayout(fig,Scrollable="on");
gl.RowHeight = repmat({'fit'},1,100);
gl.ColumnWidth = repmat({'fit'},1,10);

for k = 1:1000
uieditfield(gl);
end
drawnow
end

The approximate execution times are:

R2022a: 17.3 s

R2022b: 10.6 s

The code was timed on a Windows 10, Intel Xeon CPU E5-1650 v4 @ 3.60 GHz test system by running
the timingApp function and measuring the time it takes for the edit fields to appear in the UI figure
window.

App Building: Improved startup performance for apps with multiple


tabs
In addition to the overall app startup performance improvement in R2022b, apps that contain
multiple tabs show an even greater startup performance improvement. The reason is that MATLAB
prioritizes creating the content in the visible tab over non-visible content when the app first runs.
This improvement is more noticeable for apps with a large number of UI components in unselected
tabs. The particular performance improvement that you see depends on the app layout and UI
component types.

For example, this code creates a tab group with five tabs, each containing 200 edit field components.
The code is about 1.9x faster than in the previous release.

3-43
R2022b

function timingTabApp
fig = uifigure;
tg = uitabgroup(fig);

for k1 = 1:5
t = uitab(tg);
gl = uigridlayout(t,Scrollable="on");
gl.RowHeight = repmat({'fit'},1,20);
gl.ColumnWidth = repmat({'fit'},1,10);
for k2 = 1:200
uieditfield(gl);
end
end
drawnow
end

The approximate execution times are:

R2022a: 11.8 s

R2022b: 6.3 s

The code was timed on a Windows 10, Intel Xeon CPU E5-1650 v4 @ 3.60 GHz test system by running
the timingTabApp function and measuring the time it takes for the components to appear in the UI
figure window.

If you have an app with many UI components, consider updating your app layout to take advantage of
this improvement. For more information, see Improve App Startup Time.

Compatibility Considerations
When an app user switches to a new tab for the first time after running an app, the interaction might
take more time than in previous releases. The reason is that MATLAB might create some content in
the tab only after the user selects the tab. If the user later switches to the same tab again, the
interaction does not take the additional time.

Plots in Apps: Improved responsiveness when interacting with large


images
Interactions with large images are more performant within apps and within figures created with the
uifigure function. The improvement is noticeable for images with at least 3000 pixels along one
dimension. In particular, these interactions are more responsive in R2022b than in R2022a:

• Zooming out — The image updates immediately after you zoom out of an image. Previously, there
was a delay before the image updated.
• Panning — The image updates as you are panning within an image. Previously, the image updated
after you finished panning (for example, after releasing the mouse).

For example, if you run this code on a Windows 10, Intel Xeon CPU W-2133 @ 3.60 GHz test system
with a modern graphics card, and then zoom into the resulting image and pan around, the image
updates immediately as you interact.

imdata = imread("peppers.png");
imdata2 = repmat(imdata,8,8,1);

3-44
Performance

f = uifigure;
ax = axes(f);
image(ax,imdata2)

Plots in Apps: Ticks and grid lines update as you pan


Axes ticks and grid lines update immediately as you pan within many types of Cartesian plots that are
displayed in apps. Previously, the ticks and grid lines updated after you released the mouse. Now, the
ticks update immediately for most plots that meet all of these conditions:

• They are in 2-D Cartesian space


• They display numeric data on a linear scale
• They have the default tick values and labels
• They have the default axis locations

Grid lines update immediately under the same conditions, but you can see the improvement in 3-D
views in addition to 2-D views.

For example, if you run this code on a Windows 10, Intel Xeon CPU W-2133 @ 3.60 GHz test system
and then pan within the axes, the ticks and the grid lines update immediately as you pan.

f = uifigure;
ax = uiaxes(f);
x = 1:50;
y = rand(1,50);
plot(ax,x,y);
ax.XLim = [20,30];
grid(ax,"on")

3-45
R2022b

Plots in Apps: Improved performance and smaller PDF files when


exporting complex plots
The exportgraphics function has improved performance and creates a smaller file when you export
a complex graphic as a PDF containing vector graphics. To observe the improvement, the plot must
be displayed in an app or in a figure created with the uifigure function. For example, this code
creates a figure containing a complex contour plot. Then it calls the exportgraphics function to
export the plot as a PDF containing vector graphics content. The exportgraphics function executes
about 2.1x faster, and the file size is about 23% smaller than in the previous release.

function myapp
f = uifigure;
ax = uiaxes(f);
x = linspace(-250*pi,250*pi);
y = linspace(0,500*pi);
[X,Y] = meshgrid(x,y);
Z = sin(X)+cos(Y);
contour(ax,X,Y,Z,50)
tic
exportgraphics(ax,"mycontours.pdf","contentType","vector")
toc
end

3-46
Performance

The approximate execution times (and file sizes) are:

R2022a: 16.3 s (3.45 MB)

R2022b: 7.7 s (2.66 MB)

The code was timed on a Windows 10, Intel Xeon CPU E5-2660 @ 2.20 GHz test system by calling the
myapp function:

myapp

Tiled Chart Layouts: Improved performance for flow layouts with


spanned axes
Tiled chart layouts that have the "flow" tile arrangement and axes that span several tiles are more
performant when they update. Layouts update when you make changes that affect the arrangement
of the tiles, including:

• Adding new axes


• Resizing the figure
• Customizing the appearance of the axes by setting axes properties

The performance improvement is more significant when there are axes that span many tiles. For
example, this code is about 1.4x faster than in the previous release.

function mylayout
t = tiledlayout("flow");
nexttile(t,[20 15])
nexttile(t,[20 15])
nexttile(t,[10 30])
nexttile(t,[10 30])

3-47
R2022b

nexttile(t,[10 30])
drawnow
end

The approximate execution times are:

R2022a: 0.1082 s

R2022b: 0.0788 s

The code was timed on a Windows 10, Intel Xeon CPU W-2133 @ 3.60 GHz test system using the
timeit function:

timeit(@mylayout)

ArrayDatastore Object: Improved performance when reading data


using readall
The readall function shows improved performance when reading data from an ArrayDatastore
object that has an OutputType property set to "same". The readall function increases
performance by removing unnecessary data copies. For example, this code is significantly faster than
in the previous release:

function t = timingTest
data = parquetread("airlinesmall.parquet");
arrds = arrayDatastore(data,OutputType="same");
tic;
t = readall(arrds);
toc;
end

The approximate execution times are:

R2022a: 1584.36 seconds

3-48
Performance

R2022b: 0.12 seconds

The code was timed on a Windows 10, Intel Xeon (R) W-2133 @ 3.60 GHz test system by calling the
timingTest function.

ArrayDatastore Object: Improved performance when specifying


number of rows to read
The read function shows improved performance when reading data from an ArrayDatastore object
that has an OutputType property set to "same" and a value specified for the ReadSize property.
The performance improvement increases as the ReadSize value gets larger. For example, this code
is about 4.5x faster than in the previous release:
function c = timingTest
data2 = parquetread("outages.parquet");
arrds = arrayDatastore(data2, OutputType="same",ReadSize=100);

index = 1;
c = cell([ceil(numpartitions(arrds)/100) 1]);

tic;
while hasdata(arrds)
c{index} = read(arrds);
index = index + 1;
end
toc;
end

The approximate execution times are:

R2022a: 0.90 seconds

R2022b: 0.20 seconds

The code was timed on a Windows 10, Intel Xeon (R) W-2133 @ 3.60 GHz test system by calling the
timingTest function.

parquetread Function: Improved performance reading string data


from Parquet files
The parquetread function shows improved performance when reading string data from a Parquet
file. For example, this code is about 1.23x faster than in the previous release:
function t = timingTest
info = parquetinfo("airlinesmall.parquet");
varNames = info.VariableNames(info.VariableTypes == "string");

tic;
for i = 1:20
t = parquetread("airlinesmall.parquet",SelectedVariableNames=varNames);
end
toc;
end

The approximate execution times are:

3-49
R2022b

R2022a: 4.93 seconds

R2022b: 4.00 seconds

The code was timed on a Windows 10, Intel Xeon (R) W-2133 @ 3.60 GHz test system by calling the
timingTest function.

parquetDatastore Function: Improved performance when creating


datastore with large number of Parquet files
The parquetDatastore function shows improved performance when creating a datastore with a
large number of Parquet files. For example, this code runs about 2.5x faster than in the previous
release:

function pds = timingTest


filenames = repmat("airlinesmall.parquet",1000,1);

tic;
for i = 1:20
pds = parquetDatastore(filenames);
end
toc;
end

The approximate execution times are:

R2022a: 105.31 seconds

R2022b: 42.03 seconds

The code was timed on a Windows 10, Intel Xeon (R) W-2133 @ 3.60 GHz test system by calling the
timingTest function.

Workspace Browser: Improved performance of variable-deletion


dialog boxes in MATLAB Online
In MATLAB Online, confirmation dialog boxes for interactively deleting variables from the MATLAB
Workspace show improved performance. The delay between selecting Delete or Clear Workspace
for variables in the Workspace browser and the confirmation dialog box appearing is reduced.

For example, on a Windows 10, Intel Xeon CPU E5-1650 v4 @ 3.60 GHz test system, when you right-
click a single variable in the workspace and select Delete, the confirmation dialog box appears more
quickly in R2022b than in R2022a.

Variables Editor and Live Editor: Improved speed of data display when
scrolling in MATLAB Online
In MATLAB Online, for variables in the Variables editor or in the generated output of the Live Editor,
the performance of vertical and horizontal scrolling is improved. Improved infinite scrolling queries
data more efficiently, so data appears more quickly after scrolling in R2022b than in the previous
release.

3-50
Performance

For example, on a Windows 10, Intel Xeon CPU E5-1650 v4 @ 3.60 GHz test system, when you scroll
through a table with 3000 rows, the displayed data renders more quickly in R2022b than in R2022a.

lookfor Function: Improved performance when searching


The lookfor function shows improved performance when searching for keywords.

For example, if you use the lookfor function to search for the keyword inverse in the summary
line of all the references pages in the MathWorks documentation, search results appear about 36x
faster than in the previous release.

function timingTest
lookfor inverse
end

The approximate execution times are:

R2022a: 6.8885 s

R2022b: 0.1909 s

Similarly, if you use the lookfor function to search for the keyword inverse in the summary line
and the Syntax, Description, Input Arguments, Output Arguments, and See Also sections of all the
reference pages in the MathWorks documentation, search results appear about 5x faster than in the
previous release.

function timingTest
lookfor inverse -all
end

The approximate execution times are:

R2022a: 9.5596 s

R2022b: 1.7926 s

The code was timed on a Windows 10, Intel Xeon CPU W-2133 @ 3.60 GHz test system using the
timeit function.

timeit(@timingTest)

3-51
R2022b

Software Development Tools

Build Tool: Create and run software-build tasks


You can use a standard programming interface to create and run software-build tasks in a uniform
and efficient way. For example, you can create tasks that identify code issues, run tests, and package
a toolbox in a single build file in your project root folder, and then invoke the build tool to run these
tasks. For more information, see Overview of MATLAB Build Tool.

Dependency Analyzer: New warnings to identify problems


When you run a dependency analysis, the Dependency Analyzer now warns about files that contain a
syntax error. See Investigate and Resolve Problems.

Project API: Extract project from archive


You can now extract a project from an archive by using matlab.project.extractProject.

Source Control in MATLAB Online: Manage Git branches and


repositories
You can now manage Git branches and repositories in MATLAB Online:

• Create, switch, merge, and delete branches.


• Find and compare commits.
• Create branches from a tag or a revision.
• View the history of a Git repository.
• Manage multiple Git repositories at once.

Unit Testing Framework: Add methods and properties to test classes


interactively
You can add code to your test classes interactively. With a file defining your class-based test in the
Editor, go to the Editor tab and in the Test section, choose whether to add a method or
parameterization property at the test level, method-setup level, or class-setup level. For more
information, see Insert Test Code Using Editor.

Unit Testing Framework: Specify action to take against invalid test


files
You can specify whether the framework issues a warning or throws an error when it encounters an
invalid test file in a folder or package. To specify the action, use the InvalidFileFoundAction
name-value argument. For example, s = testsuite(pwd,InvalidFileFoundAction="error")
creates a test suite only if the current folder does not contain invalid test files and throws an error
otherwise. Examples of invalid test files include a test file that contains syntax errors, a function-
based test file that is missing local functions, and a file with a Test method that is passed an
undefined parameterization property.

3-52
Software Development Tools

You can specify the InvalidFileFoundAction name-value argument for these methods and
functions:

• matlab.unittest.TestSuite.fromFolder
• matlab.unittest.TestSuite.fromPackage
• testsuite
• runtests
• runperf

Unit Testing Framework: Generate descriptive test parameter names


using cell arrays
Starting in R2022b, when you assign a nonempty cell array to a parameterization property, the
testing framework generates parameter names from the elements of the cell array by taking into
account their values, types, and dimensions. In previous releases, if the property value is a cell array
of character vectors, the framework generates parameter names from the values in the cell array.
Otherwise, the framework specifies parameter names as value1, value2, …, valueN.

For example, create a test class with parameterization properties that are set using cell arrays.

classdef SampleTest < matlab.unittest.TestCase


properties (TestParameter)
numericArray = {int16(1),single(zeros(1,4)),magic(3)};
functionHandle = {@false,@() size([])};
end
methods (Test)
function test1(testCase,numericArray)
testCase.verifyNotEmpty(numericArray)
end
function test2(testCase,functionHandle)
testCase.verifyWarningFree(functionHandle)
end
end
end

Create a test suite from the class and return the names of the suite elements.

R2022a and Earlier Starting in R2022b


suite = testsuite("SampleTest"); suite = testsuite("SampleTest");
{suite.Name}' {suite.Name}'

ans = ans =

5×1 cell array 5×1 cell array

{'SampleTest/test1(numericArray=value1)' } {'SampleTest/test1(numericArray=int16_1)'
{'SampleTest/test1(numericArray=value2)' } {'SampleTest/test1(numericArray=1x4_single)'
{'SampleTest/test1(numericArray=value3)' } {'SampleTest/test1(numericArray=3x3_double)'
{'SampleTest/test2(functionHandle=value1)'} {'SampleTest/test2(functionHandle=@false)'
{'SampleTest/test2(functionHandle=value2)'} {'SampleTest/test2(functionHandle=function_handle

3-53
R2022b

Compatibility Considerations
If you use parameter names in your code to create or filter test suites, use the descriptive parameter
names. This table shows an example of how to update code that filters the test suite created from the
SampleTest class.

Before After
import matlab.unittest.selectors.HasParameter
import matlab.unittest.selectors.HasParameter
s = ~HasParameter("Property","numericArray","Name","value1");
s = ~HasParameter("Property","numericArray","Name","i
suite2 = selectIf(suite,s); suite2 = selectIf(suite,s);

Unit Testing Framework: Compare dictionaries in tests


The IsEqualTo constraint supports MATLAB dictionaries. The constraint treats two dictionaries as
equal if they have the same keys and the values assigned to corresponding keys also satisfy the
constraint. For example, this test passes.

import matlab.unittest.TestCase
import matlab.unittest.constraints.IsEqualTo
import matlab.unittest.constraints.DictionaryComparator
import matlab.unittest.constraints.NumericComparator

testCase = TestCase.forInteractiveUse;
actual = dictionary(["key1" "key2"],[1 2]);
expected = dictionary("key1",1,"key2",2);
testCase.verifyThat(actual,IsEqualTo(expected, ...
Using=DictionaryComparator(NumericComparator)))

To override how dictionaries are compared by IsEqualTo, use the


matlab.unittest.constraints.DictionaryComparator class.

Functionality being removed or changed


pack function has been removed
Errors

The pack function has been removed. There is no replacement for this function because you do not
need to use it on a 64-bit system. For more information about strategies for reducing memory usage,
see Strategies for Efficient Use of Memory and Resolve “Out of Memory” Errors.

Interactively running a test class requires the class definition file to explicitly use
framework-specific data
Behavior change

When you open a class-based test file in the MATLAB Editor, you can interactively run the tests in the
file only if the test class explicitly subclasses a TestCase class, uses framework-specific attributes to
specify test content, or both. In previous releases, the testing framework tries to examine the class
hierarchy whenever it cannot determine if a class definition file contains a test class. This change of
behavior prevents checks that might take a long time to complete.

For example, consider an abstract test class defined to test if a function supports implicit expansion
of a scalar input.

3-54
Software Development Tools

classdef ScalarExpansionTest < matlab.unittest.TestCase


properties (Abstract)
FcnHandle
end
methods (Test)
function supportsScalarExpansion(testCase)
fcn = testCase.FcnHandle;
result = fcn(1,1:5);
testCase.verifySize(result,[1 5], ...
"Result must be a 1-by-5 vector.");
end
end
end

To test scalar expansion with a specific function interactively, make sure to specify framework-specific
data when you create a concrete test class from ScalarExpansionTest. If your test class does not
require any framework-specific attributes (such as Test, TestParameter, and TestTags), consider
deriving it explicitly from matlab.unittest.TestCase. In this example, you can run PlusTest
interactively because the framework can determine the class type using the contents of the class
definition file.

classdef PlusTest < ScalarExpansionTest & matlab.unittest.TestCase


properties
FcnHandle = @plus;
end
end

3-55
R2022b

External Language Interfaces

.NET Interface: Support for .NET 5 and .NET Core


On Microsoft Windows platforms, MATLAB supports loading libraries compiled for .NET 5 and higher
and for .NET Core, in addition to existing support for the Microsoft .NET Framework. To select
a .NET environment, use the dotnetenv function. For more information, see Selecting .NET Core in
MATLAB.

.NET Engine API: Call MATLAB from .NET applications


The MATLAB Engine API for .NET provides an interface between .NET programming languages and
MATLAB. This API enables programs to launch MATLAB, evaluate MATLAB functions with arguments,
and exchange data between MATLAB and .NET programs. For more information, see Call MATLAB
from .NET and MathWorks.MATLAB.Engine.MATLABEngine.

If you write code that calls MATLAB as a COM Automation server using the MATLAB COM
Automation Server Interface, consider using the MATLAB Engine API for .NET instead.

Publish C++ Interface: Support for char* output as nullTerminated


string
You can specify a nullTerminated string for char* and const char* return types. For details, see
the C++ Return Type table with the C++ to MATLAB data type mapping for C++ char* and
char[] Types.

Call MATLAB from C++: Use MATLAB enumeration classes in strongly-


typed interface
To generate C++ code from a MATLAB enumeration, use the Classes name-value argument with
the matlab.engine.typedinterface.generateCPP function. For example, to create a header file
InterfaceCode.hpp from a MATLAB enumeration class MyColorEnum with a function
printMyText, type:
matlab.engine.typedinterface.generateCPP("InterfaceCode.hpp",Classes="MyColorEnum",Functions="printMyText")

Python Interface: Display keyword (key-value pair) arguments created


by pyargs
The pyargs function displays keyword (key-value pair) arguments.

pyargs(A=1,B=2)

ans =

'pyargs' with pairs:

A: 1
B: 2

3-56
External Language Interfaces

Python Interface: Convert scalar logical and numeric Python types to


MATLAB types
You can convert Python data types py.int, py.long, py.float, and py.bool to MATLAB types
using these MATLAB functions:

• double
• single
• int8
• uint8
• int16
• uint16
• int32
• uint32
• int64
• uint64
• logical

For information about conversion functions, see MATLAB to Python Data Type Mapping.

Python Engine: Pass NumPy arrays directly to MATLAB functions


Calls to MATLAB functions from Python engine applications accept any object that implements the
Python buffer protocol, like NumPy arrays, as an input argument.

For example, this code calls the built-in MATLAB function sum with a NumPy ndarray buf as input.

import matlab.engine
import numpy
eng = matlab.engine.start_matlab()
buf = numpy.array([[1, 2, 3], [4, 5, 6]], dtype='uint16')

# Supported in R2022a and earlier: must initialize a matlab.uint16 from


# the numpy array and pass it to the function
array_as_matlab_uint16 = matlab.uint16(buf)
res = eng.sum(array_as_matlab_uint16, 1, 'native')
print(res)

# Supported as of R2022b: can pass the numpy array


# directly to the function
res = eng.sum(buf, 1, 'native')
print(res)

For information about using the MATLAB Engine API for Python, see Call MATLAB from Python.

Python Engine: Install MATLAB Engine API with pip Command


You can use the pip command to install the MATLAB Engine API. For more information, see Install
MATLAB Engine API for Python.

3-57
R2022b

Python: Support for Version 3.10


MATLAB now supports CPython version 3.10, in addition to existing support for versions 2.7, 3.8, and
3.9. For more information, see Versions of Python Compatible with MATLAB Products by Release.

Functionality being removed or changed


C++ library definition file has .m file extension
Behavior change

The clibgen.generateLibraryDefinition function creates library definition files with .m file


extensions. The function no longer creates a file with the .mlx file extension. You can continue to
modify and build existing library definition files with the .mlx file extension.

For information about editing the library definition file, see How to Complete Definitions in Library
Definition File. While following the instructions, note that when you uncomment the code defining a
function, do not uncomment the first two lines in the code section. These comments contain the
section title and the C++ signature help.

Python: Version 2.7 support will be discontinued in a future release


Behavior change in future release

Support for Python version 2.7 will be discontinued in a future release.

To ensure continued support for interacting between Python and MATLAB, consider upgrading to a
supported version of Python. For supported version information, see Versions of Python Compatible
with MATLAB Products by Release.

3-58
Hardware Support

Hardware Support

Upload Libraries and Configure Pins for I2C, SPI, and Serial
Communication Using the Arduino Explorer App
The Arduino® Explorer app, which was introduced in R2021b release of MATLAB Support Package for
Arduino Hardware, now supports selecting and uploading the required libraries for the initial setup of
the Arduino board. The modified app also allows you to configure pins on the Arduino board for I2C,
SPI, and Serial communication, and plot the values. You can also add decode logic on the read values
and view the values in the Log panel of the app.

Support for servo and rotary encoder peripherals connected to


Arduino-compatible ESP32 boards
In addition to the existing support for communicating with I2C, SPI and serial peripherals connected
to Arduino-compatible ESP32 board, the MATLAB Support Package for Arduino Hardware now
supports communicating with servo and rotary encoder peripherals connected to the board.

3-59
4

R2022a

Version: 9.12

New Features

Bug Fixes

Compatibility Considerations
R2022a

Environment

Themes in MATLAB Online: Change the colors of the MATLAB desktop


by selecting a dark or light theme
In MATLAB Online, you can change the colors of the MATLAB desktop using themes.

For example, to select a dark theme, on the Home tab, in the Environment section, click
Preferences. Select MATLAB > Appearance and set the Theme to Dark.

To further customize the colors of the MATLAB desktop, select MATLAB > Appearance > Colors.
Then, change the colors in the Desktop tool colors, MATLAB syntax highlighting colors, and
MATLAB output colors sections.

As part of this change, icons in the MATLAB Online desktop have an improved visual appearance.

For more information about changing the colors of the MATLAB desktop, see Change Desktop Colors.

4-2
Environment

Live Editor Colors: Change the text and background colors of live
scripts and functions
You can change the text and background colors in the Live Editor by changing the MATLAB desktop
tool colors.

To change the text and background colors:

1 On the Home tab, in the Environment section, click Preferences.


2 Select MATLAB > Colors

In MATLAB Online, select MATLAB > Appearance > Colors.


3 In the Desktop tool colors section, clear the Use system colors check box.

In MATLAB Online, the Use system colors check box is not available and this step can be
skipped.
4 Use the Text and Background fields to change the colors. For example, select white for the text
color and black for the background color.

The Live Editor automatically selects colors for titles and headings based on the selected background
color. To further customize the colors of titles and headings, use settings. For more information, see
matlab.fonts Settings.

Live Editor Hyperlinks: Insert hyperlinks to specific locations in


separate live scripts or live functions
Use hyperlinks to navigate to a location in a separate, existing live script or function. To insert a
hyperlink, select the text to link in the current file, go to the Insert tab, and click Hyperlink. Edit
your display text (optional), select Location in existing document, and enter or browse for the file
path. Then, select a location in the document preview that displays on the right.

For more information about inserting hyperlinks, see Format Text in the Live Editor.

Live Editor Export: Export live scripts and functions programmatically


using the export function
Use the export function to programmatically export live scripts and functions to a standard format.
Available formats include PDF, Microsoft Word, HTML, and LaTeX.

For example, to export the live script homework1.mlx as HTML, type:

export("homework1.mlx","homework1.html")

Live Editor Accessibility: Interact with output in live scripts using the
keyboard
You can now use keyboard shortcuts to interact with output in live scripts when output is on the right.
To move focus from the code to the output display panel, press Ctrl+Shift+O. On macOS, press
Option+Command+O. To activate an output, press Enter. Once an output is activated, you can

4-3
R2022a

scroll text using the arrow keys, navigate through hyperlinks and buttons using the Tab key, and open
the context menu by pressing Shift+F10.

Live Editor Tasks: View and interact with tasks when code is hidden
When you hide code in a live script, the Live Editor now displays Live Editor tasks along with
formatted text, labeled controls, and output.

To hide code, select the Hide Code button to the right of the live script or in the View tab.
Alternatively, if you are using the export function, you can hide the code using the HideCode name-
value argument.

If a Live Editor task is configured to show only code and no controls, then the task does not display
when you hide code.

Component Browser: Reorder children in App Designer or the Property


Inspector
You can now drag one or more Axes object children, Group object children, or Transform object
children sharing the same parent to reorder them in the Component Browser in App Designer or the
Property Inspector for figures.

When reordering children, use visual feedback for allowed moves. You can undo and redo the
reordering of the children with Undo or Redo or the corresponding keyboard shortcuts.

Editor Python Support: View and edit Python files with syntax
highlighting, auto-indenting, and delimiter matching
The Editor now displays Python files with syntax highlighting for keywords, strings, comments, and
errors. In addition, the Editor auto-indents Python files and indicates matched and mismatched
delimiters such as parentheses, brackets, and braces.

Find and Replace Dialog Box: Search text in the Editor and Live Editor
using regular expressions
You can use a subset of regular expressions to search for text that matches a pattern in an open file in
the Editor or Live Editor. To search using a regular expression, on the Editor or Live Editor tab, in

the Navigate section, click Find. Then, in the find and replace dialog box, enter a regular
expression, and select the Regular Expression button .

For example, to find all the words in a file that contain the letter x, enter the expression \w*x\w* and
select the Regular Expression button .

For more information, see Find and Replace Text in Files and Go to Location.

4-4
Environment

Profiler: Access the Profiler from the Apps tab


The MATLAB Profiler is now available as an app and can be found in the MATLAB section of the apps
gallery in the Apps tab.

You can still access the Profiler from the Home tab, in the Code section, by clicking the Run and
Time button, or programmatically using the profile function.

Internationalization: UTF-8 system encoding on Windows platforms


MATLAB now uses UTF-8 as its system encoding on Windows, completing the adoption of Unicode®
across all supported platforms. MATLAB has used UTF-8 as the default encoding for MATLAB files
and file I/O since R2020a.

If you see garbled characters on a Windows Server® 2019 platform, then enable the Beta: Use
Unicode UTF-8 for worldwide language support option in Region Settings.

Installation Settings: Configure persistent settings for MATLAB


installations
Installation-level settings provide a new layer of MATLAB configuration that lies between factory
settings and personal settings. Installation settings override the factory settings for all users of a
given MATLAB installation, and they are persistent across sessions.

In previous versions of MATLAB, if administrators wanted to limit RAM usage for a set of MATLAB
users by lowering the ArraySizeLimit, they had to create and distribute a script to change the
personal setting for each individual user. Starting in R2022a, the administrator can apply the change
to all users of their MATLAB installation using the installation setting for ArraySizeLimit.

Access installation-level settings using the new InstallationValue property of the Setting
object. Verify and clear installation settings with two new object functions, hasInstallationValue
and clearInstallationValue, respectively.

Comparison Tool: Save results as HTML report


You can now use the Comparison Tool to publish text comparison results in an HTML report. For
more details, see Compare Text Files.

Comparison Tool: Compare folders in MATLAB Online


Starting in R2022a, you can compare folders and zip files in MATLAB Online.

You can access the comparison tool from:

• The MATLAB Current Folder browser context menu


• The Current Project browser context menu
• The MATLAB Command Window using the visdiff function

4-5
R2022a

MATLAB Drive: macOS 10.15 Catalina will no longer receive updates to


MATLAB Drive Connector (April 2022)
After this release, macOS 10.15 Catalina will no longer receive updates to MATLAB Drive™
Connector.

Installing later versions of MATLAB Drive Connector on macOS 10.15 Catalina will not be supported.
In addition, the Connector will not automatically update to a later version when one becomes
available.

Functionality being removed or changed


Live Editor figure size is bounded upon saving
Behavior change

When opening a saved live script, existing images in the output have a maximum size equivalent to
the figure size upon saving. To adjust the size past this maximum limit, you can run the live script and
increase the figure size.

4-6
Language and Programming

Language and Programming

Class Introspection: Description and DetailedDescription properties of


metaclasses contain text from code comments
The Description and DetailedDescription properties of these metaclasses pull content from
code comments:

• meta.class
• meta.method
• meta.property
• meta.event
• meta.EnumeratedValue

For user-defined classes with appropriately placed code comments, the Description and
DetailedDescription properties of the metaclasses are populated with text pulled from those
comments. For more information on how to use code comments to store custom help text for user-
defined classes, see Custom Help Text.

Class Introspection: Access class aliases from meta.class instance


The aliases of a class are stored in the new Aliases property of meta.class. For more information
on class aliasing, see Creating and Managing Class Aliases.

Background Pool: See futures in the background


Starting in R2022a, you can query all queued and running futures in the background by using the
FevalQueue property of the pool. To create futures, use parfeval and parfevalOnAll. For more
information on futures, see Future.

cancelAll Method: Cancel currently queued and running futures in the


background pool
cancelAll cancels all futures currently queued or running in the background pool. Queued or
running futures are listed in the FevalQueue property.

Background Pool: Check the status of the background pool


Starting in R2022a, you can query to determine if the background pool is currently running by using
the Busy property of the pool. This property indicates whether the background pool is busy, specified
as true or false. The pool is busy if there is outstanding work for the pool to complete.

pcode Function: Create P-code files with enhanced obfuscation


The pcode function now has the option "-R2022a", which creates P-code files using a more complex
obfuscation algorithm. Files created with this option run only in MATLAB releases R2022a and later.

4-7
R2022a

str2num Function: Restrict evaluation to basic math expressions


str2num is implemented using the eval function, which evaluates the input argument. Starting in
R2022a, you can set the name-value argument Evaluation to "restricted" to restrict accepted
inputs to basic math expressions, such as 200 and 1+2i.

assert Function: Output displays which assertion threw an error and


the location in the code
When an assertion fails, the error thrown includes the specific assertion that failed and the location in
the code.

Previous Output New Output


Error using repro>checkScalarInteger Error using assert
Assertion failed. Assertion failed.

Error in repro (line 4) Error in assert_test>checkScalarInteger (line 6)


checkScalarInteger(pi) assert(x == floor(x))

Error in assert_test (line 3)


checkScalarInteger(pi)

Functionality being removed or changed


Defining classes and packages: Using schema.m will not be supported in a future release
Still runs

Support for classes and packages defined using schema.m files will be removed in a future release.
Replace existing schema-based classes with classes defined using the classdef keyword.

dec2hex and dec2bin input types are now restricted


Behavior change

Input types allowed by dec2hex and dec2bin have been restricted. Supported input types are
primitive numeric types and classes that inherit from a primitive numeric type.

In addition, dec2bin(0,0) will now return ‘0’ rather than a 1x0 character vector.

cd no longer removes leading spaces for Windows drive letter paths


Behavior change

Before R2022a, on Windows platforms, the cd function removed leading spaces in input paths
specifying the drive letter. Input paths containing leading spaces now cause an error to be thrown
instead. If an input path is invalid with leading spaces, then use strip to remove the spaces before
using the cd function.

TruncateScalarObject name-value argument for widthConstrainedDataRepresentation


method renamed to AllowTruncatedDisplayForScalar
Behavior change in future release

The name of the TruncateScalarObject name-value argument for the


widthConstrainedDataRepresentation method is now AllowTruncatedDisplayForScalar.

4-8
Language and Programming

The functionality of the option will not change. Support for the name TruncateScalarObject will
be removed in a future release.

cast returns consistent output for subclass of MATLAB numeric types


Behavior change

The syntax cast(A,"like",p) now returns output consistent with the prototype p when the data
type of p is a subclass of MATLAB numeric types.

For example, this code returns an output that has the same data type as p:

p = matlab.lang.OnOffSwitchState.on;
x = cast(1,"like",p)

x =

OnOffSwitchState enumeration

on

In previous releases, the code returns x = 1 with data type logical.

Error reports will no longer include line number


Behavior change

Thrown error reports will no longer include the line number of where the error occurred.

4-9
R2022a

Data Analysis

Data Cleaner App: Interactively preprocess and organize column-


oriented data
The new Data Cleaner app enables you to:

• Access column-oriented data in the MATLAB workspace or import column-oriented data from a
file.
• Explore data by using the visualization, data, and summary views.
• Sort by a variable, rename a variable, or remove a variable.
• Retime data in a timetable, stack or unstack table variables, clean missing data, clean outlier data,
smooth data, or normalize data.
• Edit previously performed cleaning steps by using the Cleaning Steps panel.
• Export cleaned data to the MATLAB workspace, or export code for cleaning data as a script or
function.

You can open the Data Cleaner app from the MATLAB section of the apps gallery in the Apps tab.
Alternatively, enter dataCleaner in the MATLAB command window.

The Data Cleaner app currently supports cleaning only timetable data and importing only one
timetable at a time.

allfinite, anynan, and anymissing Functions: Determine if all array


elements are finite, any element is NaN, and any element is missing
Use the allfinite, anynan, and anymissing functions to examine the elements of an input array.

• allfinite: Determine if all array elements are finite.


• anynan: Determine if any array element is NaN.
• anymissing: Determine if any array element is missing.

quantile, prctile, and iqr Functions: Calculate quantiles, percentiles,


and interquartile range
Calculate quantiles, percentiles, and the interquartile range of a data set by using the quantile,
prctile, and iqr functions.

Previously, the quantile, prctile, and iqr functions required Statistics and Machine Learning
Toolbox.

rms Function: Calculate root-mean-square value


Calculate the root-mean-square (RMS) value of input data with rms.

You can specify the dimensions to operate along and whether to include or omit NaN values in the
calculation:

4-10
Data Analysis

• Use "all" to calculate the RMS value of all elements of the input array.
• Use the dim input argument to calculate the RMS value along one dimension.
• Use the vecdim input argument to calculate the RMS value along multiple dimensions.
• Use "includenan" or "omitnan" to include or omit NaN values in the RMS calculation.

Previously, the rms function required Signal Processing Toolbox™.

std and var Functions: Optionally return mean as a second output


The std and var functions can now return the mean of the elements used to calculate the standard
deviation or variance by using a second output argument M. If a weighting scheme is specified, then
the weighted mean is returned.

Date and Time Functions: Some Financial Toolbox functions combined


with MATLAB functions
The following date and time functions from Financial Toolbox™ are combined with functions having
the same names in MATLAB. Before R2022a, these Financial Toolbox functions supported serial date
numbers and text timestamps as inputs, while the MATLAB functions supported datetime arrays.
Starting in R2022a, the MATLAB functions support datetime arrays, serial date numbers, and text
timestamps as inputs. The functions are removed from Financial Toolbox.

• day
• hour
• minute
• month
• quarter
• second
• year

Compatibility Considerations
While these functions support serial date number and text inputs, these types of inputs are not
recommended. Use datetime values as inputs instead. The datetime data type provides flexible
date and time formats, storage out to nanosecond precision, and properties to account for time zones
and daylight saving time. To convert serial date numbers or text timestamps to datetime values, use
the datetime function.

• To convert serial date numbers to datetime values, call datetime with the ConvertFrom name-
value argument:

dt = datetime(738457,"ConvertFrom","datenum")

dt =

datetime

28-Oct-2021

4-11
R2022a

• To convert text timestamps, call datetime.

dt = datetime("2021-10-28")

dt =

datetime

28-Oct-2021

There are no plans to remove support for serial date numbers or text timestamps from these MATLAB
functions.

Date and Time Functions: Some Financial Toolbox functions moved to


MATLAB
These date and time functions are removed from Financial Toolbox and moved to MATLAB:

• eomdate
• lweekdate
• m2xdate
• months
• nweekdate
• today
• weeknum
• x2mdate

Compatibility Considerations
While MATLAB supports these functions, they are not recommended because they use serial date
numbers in their calculations. The table shows recommended replacements that either accept or
return datetime values. The datetime data type is recommended because it provides flexible date
and time formats, storage out to nanosecond precision, and properties to account for time zones and
daylight saving time.

There are no plans to remove these functions from MATLAB.

Transferred Function Recommended Replacement


eomdate dateshift, with datetime values as inputs
lweekdate lweekdate, with outputType specified as
"datetime" to return datetime output
m2xdate exceltime, with datetime values as inputs
months between, with datetime values as inputs
nweekdate nweekdate, with outputType specified as
"datetime" to return datetime output
today datetime, with "today" as the input argument
weeknum week, with datetime values as inputs

4-12
Data Analysis

Transferred Function Recommended Replacement


x2mdate datetime, with dateType specified as "excel"

matlab.datetime.compatibility.convertDatenum Function: Convert text


timestamps and serial date numbers to datetime values in a
backward-compatible way
To convert text timestamps and serial date numbers to datetime values, use the
matlab.datetime.compatibility.convertDatenum function. For backward compatibility, this
function supports the subset of datestr formats that the datenum function recognizes when it
converts text timestamps without a format specifier.

Use this function in code where you intend to return datetime values, but to preserve compatibility
you need to interpret text inputs in the same way that datenum interprets them. This function is
designed to be a compatibility layer for function authors.

To explicitly convert serial date numbers to datetime values, use the datetime function instead,
with the ConvertFrom name-value argument:
dt = datetime(738457,"ConvertFrom","datenum")

dt =

datetime

28-Oct-2021

categorical Data Type: Use a pattern object to specify category names


that match a pattern
When you specify category names of a categorical array, you can use a pattern object to specify
names that match a pattern.

For example, suppose you have a categorical array that has many different categories that can
represent "yes" and "no". This categorical array has six values and six categories because the values
in the input array are different.
C = categorical(["Y" "Yes" "Yeah" "N" "No" "Nope"])

C =

1×6 categorical array

Y Yes Yeah N No Nope

To combine all the different "yes" categories into one category and all the different "no" categories
into another category, use the mergecats function and wildcard patterns to match the category
names. The categorical array still has six values. But it has only two categories, "yes" and "no".
C = mergecats(C,"Y" + wildcardPattern,"yes");
C = mergecats(C,"N" + wildcardPattern,"no")

C =

4-13
R2022a

1×6 categorical array

yes yes yes no no no

These functions provide support for using patterns when you specify category names:

• histcounts (when you specify the Categories argument)


• iscategory (when you specify the catnames argument)
• mergecats (when you specify the oldcats argument)
• removecats (when you specify the oldcats argument)
• reordercats (when you specify the neworder argument)

table and timetable Data Types: Use a pattern object to specify row,
variable, and property names that match a pattern
When you specify rows, variables, or properties of a table or timetable, you can use a pattern object
to specify names that match a pattern.

You can use patterns when you subscript into a table by row names and variable names, or when you
subscript into a timetable by variable names.

For example, read a table into MATLAB.

T = readtable("outages.csv","TextType","string")

T =

1468×6 table

Region OutageTime Loss Customers RestorationTime Cause


___________ ________________ ______ __________ ________________ __________________

"SouthWest" 2002-02-01 12:18 458.98 1.8202e+06 2002-02-07 16:50 "winter storm"


"SouthEast" 2003-01-23 00:49 530.14 2.1204e+05 NaT "winter storm"
"SouthEast" 2003-02-07 21:15 289.4 1.4294e+05 2003-02-17 08:14 "winter storm"
: : : : : :

To subscript into the table and select all variables whose names end with "Time", use a wildcard
pattern.

T2 = T(:,wildcardPattern + "Time")

T2 =

1468×2 table

OutageTime RestorationTime
________________ ________________

2002-02-01 12:18 2002-02-07 16:50


2003-01-23 00:49 NaT
2003-02-07 21:15 2003-02-17 08:14
: :

These functions provide support for using patterns when you specify variables by name:

• convertvars

4-14
Data Analysis

• innerjoin
• issortedrows
• join
• movevars
• mergevars
• outerjoin
• removevars
• rowfun
• rows2vars
• sortrows
• splitvars
• stack
• topkrows
• unstack
• varfun

This function provides support for using patterns when you specify properties by name:

• rmprop

Data Preprocessing Functions: Append transformed variables to input


data using the ReplaceValues name-value argument
When you preprocess tables and timetables, you can now append variables containing the
transformed values to the input table. Set the ReplaceValues name-value argument to false for
these functions:

• smoothdata
• normalize
• filloutliers
• fillmissing
• standardizeMissing

Data Preprocessing Functions: Return table with logical values using


the OutputFormat name-value argument
When you preprocess tables and timetables, you can now output a table or timetable containing
logical values instead of a logical array. Set the OutputFormat name-value argument to "tabular"
for these functions:

• ischange
• islocalmax
• islocalmin
• ismissing

4-15
R2022a

• isoutlier

ismissing, rmmissing, and groupsummary Functions: Accept data


types with no standard missing value
The ismissing syntax ismissing(A) now returns logical 0 (false) when the input data type has
no default definition of a standard missing value.

rmmissing and the nummissing and nnz methods of groupsummary no longer error for input data
types with no default definition of a standard missing value.

An example of code that used to error but now executes is:

A = [struct struct struct];


TF = ismissing(A)

TF =
1x3 logical array
0 0 0

Compatibility Considerations
Some input types that used to throw an error now execute. If your code relies on the errors that
MATLAB threw for those inputs, such as within a try/catch block, then your code may no longer
catch those errors.

Functionality being removed or changed


Plot a variable multiple times in a stacked plot
Behavior change

You can now display the same table or timetable variable multiple times when you call the
stackedplot function. In previous releases, specifying a variable more than once results in an error.

For example, create a timetable from the outages.csv file. Then plot the RestorationTime
variable under each of the other variables that you specify.

tbl = readtimetable("outages.csv");
tbl = sortrows(tbl);
stackedplot(tbl,["Loss","RestorationTime","Customers","RestorationTime"])

Live Editor tasks for arrays, tables, and timetables do not run automatically if inputs have
more than 1 million elements
Behavior change

Many Live Editor tasks for arrays, tables, and timetables do not run automatically if inputs have more
than 1 million elements. In previous releases, these tasks run automatically for input arrays, tables,
and timetables of any size. If the inputs have a large number of elements, then the code generated by
these tasks can take a noticeable amount of time to run (more than a few seconds).

This change in behavior affects these tasks:

• Join Tables

4-16
Data Analysis

• Retime Timetable
• Stack Table Variables
• Synchronize Timetables
• Unstack Table Variables

Live Editor tasks for preprocessing data do not run automatically if inputs have more than
1 million elements
Behavior change

Many Live Editor tasks for preprocessing data do not run automatically if inputs have more than 1
million elements. In previous releases, these tasks run automatically for input data of any size. If the
inputs have a large number of elements, then the code generated by these tasks can take a noticeable
amount of time to run (more than a few seconds).

This change in behavior affects these tasks:

• Clean Missing Data


• Clean Outlier Data
• Compute by Group
• Find Change Points
• Find Local Extrema
• Normalize Data
• Smooth Data
• Remove Trends

4-17
R2022a

Data Import and Export

Parquet: Read Parquet file data more efficiently using rowfilter to


conditionally filter rows
Conditionally filter and read data faster (Predicate Pushdown) from Parquet files when using
parquetread and parquetDatastore. You can create conditions for filtering by using the
rowfilter function, matlab.io.RowFilter object, and RowFilter name-value argument. Due to
its metadata-accelerated processing, the rowfilter workflow is the recommended approach for
filtering Parquet data to import.

Parquet: Determine and define row groups in Parquet file data


A Parquet file can store a range of rows as a distinct row group for increased granularity and
targeted analysis. parquetread uses the RowGroups name-value argument to determine row groups
while reading Parquet file data. parquetwrite uses the RowGroupHeights name-value argument to
define row groups while writing Parquet file data.

Parquet: Convert, import, and export nested data structures


Use parquetread to import nested Parquet file data with:

• LogicalType as LIST.
• LogicalType as NONE and PhysicalType as either BYTE_ARRAY or FIXED_LEN_BYTE_ARRAY.

The parquetread function converts and imports these data structures as cell arrays.

Use parquetwrite to export nested cell arrays as LIST arrays. Nested data is beneficial to working
with irregularly structured data such as jagged arrays.

writelines Function: Write plain text to a file


Use the writelines function to write a string array or a cell array of character vectors as plain text
to a file. The writelines function is the writing equivalent of the readlines function.

Reading Online Data: Use web options when reading files over HTTP
and HTTPS
Read files over HTTP and HTTPS using the weboptions function and specifying the WebOptions
name-value argument with these functions:

• readtable
• readtimetable
• readvars
• readstruct
• readmatrix
• readcell

4-18
Data Import and Export

• readlines

Opus Files: Work with Opus (.opus) audio files.


Use audioread, audiowrite, and audioinfo to read, write, and analyze Ogg Opus audio files.

HDF5 Interface: Write datasets using dynamically loaded filters


You can read and write HDF5 datasets using dynamically loaded filters with both the high-level and
low-level interfaces. For details, see Import HDF5 Files and Export to HDF5 Files.

The h5create function introduces two name-value arguments, CustomFilterID and


CustomFilterParameters, to enable compression using dynamically loaded filters.

NetCDF Interface: Enable byte-range reading of remote datasets


You can now use the existing high-level and low-level interfaces for read-only access to remote
datasets using the HTTP byte-range capability. The latter assumes that the remote server supports
byte-range access.

NetCDF Interface: Read and write variable length array data types
(NC_VLEN)
You can now use the existing high-level functions to read variable length array data types (NC_VLEN)
from NetCDF-4 files. You can read and write NC_VLEN types using low-level functions.

Use these additional low-level functions to create NC_VLEN types and retrieve information about
them:

• netcdf.defVlen
• netcdf.inqUserType
• netcdf.inqVlen

Scientific File Format Libraries: NetCDF library is upgraded


The NetCDF library is upgraded to version 4.8.1.

Hardware Manager App: Discover and connect to your hardware from


MATLAB
The new Hardware Manager app allows you to discover and connect to your hardware from MATLAB
by providing access to the necessary add-ons and apps. For more information, see Get Started with
Hardware Manager.

TCP/IP Client Interface: Specify transfer delay options


You can now enable or disable a transfer delay to allow delayed acknowledgement from the
connected server for tcpclient objects and in the TCP/IP Explorer app. The transfer delay is

4-19
R2022a

enabled by default. Enabling the delay turns on Nagle's algorithm, which causes the client to collect
small segments of outstanding data and send them in a single packet when acknowledgement (ACK)
arrives from the server. Disabling it turns off Nagle's algorithm, which immediately sends data to the
network.

For the tcpclient interface, you can set the EnableTransferDelay property as a name-value
argument during object creation. For TCP/IP Explorer, you can select Transfer Delay options during
connection configuration.

For more information about this functionality, see EnableTransferDelay and Configure Connection
in TCP/IP Explorer.

Functionality being removed or changed


seriallist function will be removed
Warns

seriallist will be removed. Use serialportlist instead. For more information about updating
your code to use the recommended functionality, see Transition Your Code to serialport Interface.

serial function will be removed


Warns

serial and its object properties will be removed. Use serialport and its properties instead.

This example shows how to connect to a serial port device using the recommended functionality.

Functionality Use Instead


s = serial("COM1"); s = serialport("COM1",115200);
s.BaudRate = 115200;
fopen(s)

For more information about updating your code to use the recommended functionality, see Transition
Your Code to serialport Interface.

MATLAB Variable Editor: timeseries will no longer be supported


Warns

Viewing timeseries objects using the MATLAB Variable Editor will no longer be supported. To view
time-indexed data in the Variable Editor, use timetable instead.

4-20
Mathematics

Mathematics

pagemldivide, pagemrdivide, and pageinv Functions: Solve linear


equations and calculate matrix inverses using pages of N-D arrays
Use the pagemldivide, pagemrdivide, and pageinv functions to perform linear algebra
operations on the pages of N-D arrays. In this context, the N-D array is treated as a container for
several 2-D matrices.

• pagemldivide and pagemrdivide: Solve linear equations using the pages of N-D arrays.
• pageinv: Calculate the matrix inverse of the pages of an N-D array.

tensorprod Function: Calculate tensor products between two arrays


Use the tensorprod function to calculate tensor products between two N-D arrays. You can perform
an inner product, outer product, or a combination of the two by specifying a subset of dimensions to
contract (multiply and sum) with each other.

round Function: Control tiebreak behavior


The round function has a new TieBreaker name-value argument to specify how to break ties. You
can now specify to round ties away from zero, towards zero, to the nearest even or odd integer, or
towards positive or negative infinity.

Compatibility Considerations
Starting in R2022a, the round function always rounds ties (that are within roundoff errors) away
from zero by default. In previous releases, the round function sometimes returns inconsistent results,
where ties are rounded towards zero by default.

null and orth Functions: Specify tolerance to treat singular values


below a threshold as zero
The null and orth functions now have a second input argument that specifies a tolerance. The
tolerance determines which singular values of the input matrix are treated as zero, which can change
the number of columns returned by null and orth.

norm Function: Frobenius norm calculations support N-D arrays


Frobenius norm calculations of the form norm(X,"fro") now support N-D arrays. See norm for
more information.

equilibrate Function: Specify output format of factorization


equilibrate now has an option with values of "vector" or "matrix" to specify whether the
output arguments are returned as vectors or matrices. For large factorizations, returning the outputs
as vectors can save memory and improve efficiency.

4-21
R2022a

rand, randi, and randn Functions: Support for complex input and
RandStream object with the "like" syntax
The rand, randi, and randn functions now support complex input and a RandStream object for the
"like" syntax.

For example, you can use X = rand(m,n,"like",p) to create an m-by-n array of random numbers
of the same data type and complexity (real or complex) as p. You can also use X =
rand(s,m,n,"like",p) to generate random numbers like p from the random number stream s
(RandStream object) instead of the default global stream.

eps, flintmax, intmax, intmin, realmax, and realmin Functions: Use


"like" syntax to return scalars based on prototype object
The eps, flintmax, intmax, intmin, realmax, and realmin functions now accept the "like"
syntax to return scalars based on a prototype object.

For example, you can use f = realmax("like",p) to return the largest finite floating-point
number with the same data type, sparsity, and complexity (real or complex) as the floating-point
variable p.

qr and gsvd Functions: Option for economy-size decompositions


qr and gsvd have a new "econ" option for economy-size decompositions.

• For qr, the functionality is the same as qr(A,0) unless a third output is specified.
• For gsvd, the functionality is the same as gsvd(A,B,0).

Functionality being removed or changed


One-output qr syntax always returns upper-triangular factor
Behavior change

The syntax R = qr(A) always returns R as an upper-triangular matrix, regardless of whether A is full
or sparse. Previously, for full A, the one-output syntax returned an R matrix with intermediate data
used in the calculation located in the lower triangular portion of the matrix. See qr for more
information.

mldivide no longer uses LDL factorization for full matrices


Behavior change

mldivide no longer uses an LDL factorization for full matrices that are Hermitian indefinite. Instead,
the LU factorization is used for these matrices.

4-22
Graphics

Graphics

Plotting Table Data: Create line plots by passing tables directly to


plotting functions
Create plots by passing a table directly to any of these functions: plot, plot3, loglog, semilogx,
semilogy, and polarplot. When you specify your data as a table, Cartesian axis labels and the
legend (if present) are automatically labeled using the table variable names.

For example, create a table with the variables Temperature and Humidity. Pass the table to the
plot function as the first argument, and specify the variables you want to plot.

Temperature = (40:70)';
Humidity = (50:80)' + randn(31,1);
T = table(Temperature,Humidity);
plot(T,"Humidity","Temperature")

Data Tips: View table variable names as row labels


When plotting tabular data, the default row labels of data tips created interactively or with the
datatip function are the names of the table variables associated with the data point.

For example, create a table using the sample file patients.xls. Then, plot the Systolic,
Diastolic, and Weight variables in a bubble chart. A data tip created with datatip(b) displays
three rows. The row labels are "Systolic", "Diastolic", and "Weight".

tbl = readtable("patients.xls");
b = bubblechart(tbl,"Systolic","Diastolic","Weight");
datatip(b);

4-23
R2022a

Data Tips: View visual property values for scatter plots and bubble
charts
For scatter plots and bubble charts, data tips created interactively or with the datatip function
include by default rows for visual properties such as size, color, or transparency that are specified
with vector data.

For example, create a scatter plot of random data and define the marker sizes as vector sz. A data tip
created with datatip(s) displays three rows: X, Y, and Size. The Size row in the data tip displays
the marker size specified by sz for the associated data point.

x = linspace(0,3*pi,200);
y = cos(x) + rand(1,200);
sz = linspace(1,100,200);
s = scatter(x,y,sz);
datatip(s);

4-24
Graphics

Bubble Charts and 3-D Scatter Plots: Plot multiple data sets at once
The bubblechart, bubblechart3, polarbubblechart, and scatter3 functions now accept the
same combinations of matrices and vectors as the plot function does. As a result, you can visualize
multiple data sets at once rather than using the hold function between plotting commands.

4-25
R2022a

fontname and fontsize Functions: Specify the font and font size for
graphics objects
Use the fontname and fontsize functions to modify the fonts displayed with graphics objects such
as figures, axes, legends, tiled chart layouts, standalone visualizations, and UI components. MATLAB
applies your changes to the specified object and all the objects it contains. For example, if you change
the font on a figure, all the axes, annotations, and UI components within the figure use the new font.

exportgraphics Function: Create animated GIF files


Create animated GIF files by calling the exportgraphics function multiple times with the Append
name-value argument.

Annotation Graphics Objects: Change the annotation rotation angle


with the Rotation property
For text box, rectangle, and ellipse annotation objects, rotate the annotation a specified number of
degrees by using the Rotation property. The anchor point for rotation is the location specified by
the first two elements of the Position property, so the Position property is unaffected by rotation.

For more information, see TextBox Properties, Rectangle Properties, and Ellipse Properties.

Quiver Plots: Align the heads, centers, or tails of arrows with data
points
Set the Alignment property of a Quiver object to control how the arrows align with the data points.
Valid values are "head", "center", and "tail". For example, plot a grid of vectors with the arrow
heads positioned at the data points. Specify a marker symbol to show the locations of the data points.

[X,Y] = meshgrid(0:6,0:6);
U = 0.25*X;
V = 0.5*Y;
quiver(X,Y,U,V,"Alignment","head","Marker","o")

4-26
Graphics

xlim, ylim, and zlim Functions: Query the axis limit method
Query the method MATLAB uses to set the axis limits by calling the xlim, ylim, and zlim functions
and specifying "method" as an input argument.

view Function: Change the view on multiple axes simultaneously


Change the view of multiple axes objects at the same time by passing an array of axes objects to the
view function.

rendererinfo Function: Get renderer information without specifying


the axes
Call the rendererinfo function without any arguments to query the default graphics renderer
information. This new syntax allows you to call the rendererinfo function in a way that is
consistent with the opengl syntax. Since R2019a, the rendererinfo function has been
recommended instead of the opengl function for querying the renderer.

linkaxes Function: Synchronize axes in all dimensions by default


The linkaxes function now supports 3-D Cartesian axes and synchronizes the x-axis, y-axis, and z-
axis limits by default. The supported values of the dimension input argument are now 'xyz'
(default), 'x', 'y', 'z', 'xy', 'xz', 'yz', and 'off'.

Before R2022a, linkaxes supported only 2-D Cartesian axes and synchronized the x-axis and y-axis
limits by default.

4-27
R2022a

cameratoolbar Function: Syntax support for figures created with the


uifigure function
Syntaxes of the cameratoolbar function that do not directly make the toolbar visible are now
supported by figures created with the uifigure function.

Callbacks in Live Editor: Create callbacks for figures in the Live Editor
You can now create callbacks for figures created in the Live Editor. The callback workflow supports
optional source and event-data parameters.

Keyboard-based callback properties and anonymous function callbacks using Figure objects from
the MATLAB workspace are not currently supported in the Live Editor.

To define and execute a figure callback in the Live Editor, use one of these techniques:

• Create a figure callback and pass source and event data as parameters in the callback.
• Create a figure callback and do not pass source or event data as a parameter in the callback.
• Create a callback that includes a function for identifying a graphics object, such as gca or
findobj.

For example, define a callback function called colorchangeCallback. With the


colorchangeCallback function on the MATLAB path, use the @ operator to assign the function
handle to the WindowButtonDownFcn property of the figure fig.

fig = figure;
axis([-4 4 -4 4]);
plot(1:10)
fig.WindowButtonDownFcn = @(src,eventdata)colorchangeCallback(src);

Define the callback and set the Color property for the Axes object in the figure:

function colorchangeCallback(f,~)
% Change the axes color on button down
ax = f.Children;
ax.Color = rand(1,3);
end

For more information, see Callbacks in Live Editor.

Figure Code: Generate code for figure interactions in MATLAB Online


When you modify a figure in MATLAB Online using the Figure tab, MATLAB generates code that you
can view, copy, and export. To view the generated code, select Show Code in the File section of the
Figure tab. MATLAB generates code for these actions:

• Adding a title, axis label, legend, color bar, grid, or annotation


• Changing the text or line style
• Using the pan, zoom, rotate, or data tip interactions

MATLAB does not currently generate code for the Select and Edit option in the Figure tab.

4-28
Graphics

For example, you can create a surface plot with surf(peaks). Then, interactively add a title and
colorbar, zoom into the axes, and view generated code.

Functionality being removed or changed


Polar axes display angle values with degree symbols
Behavior change

Polar axes now display tick values in degrees with degree symbols when the ThetaAxisUnits
property is set to "degrees". For example, create a polar plot. By default, the theta-axis displays the
tick values with degree symbols.

theta = 0:0.01:2*pi;
rho = sin(2*theta).*cos(2*theta);
polarplot(theta,rho)

4-29
R2022a

This change clarifies which units are being used for the theta tick values. You can use the
ThetaAxisUnits property to display the tick values in degrees or radians. To remove the degree
symbols, change the tick label format for the theta-axis:

pax = gca;
pax.ThetaAxis.TickLabelFormat = "%g";

The caxis function is not recommended


Still runs

The caxis function is no longer recommended. However, the function continues to work, and there
are no plans to remove it at this time.

To update your code, call the clim function instead. It accepts the same input arguments and returns
the same output as the caxis function.

The im2java function will be removed


Still runs

im2java will be removed in a future release. There is no replacement for this function.

The Plot Catalog tool will be removed


Still runs

The Plot Catalog tool will be removed in a future release. Instead, to interactively create and explore
visualizations for your data, use the Plots tab in the MATLAB Toolstrip or the Create Plot task in the
Live Editor.

For more information about visualizations, see Types of MATLAB Plots or toolbox-specific
documentation.

4-30
Graphics

The opengl function will be removed


Still runs

The opengl function will be removed in a future release.

• To query the renderer, use the rendererinfo function instead of the opengl function.
• Changing the renderer with the opengl function will no longer be necessary when the function is
removed.

The renderer startup options will be removed


Still runs

In a future release, the MATLAB startup options for selecting the graphics renderer will be removed.
Specifically, these startup scenarios will no longer be available:

• matlab -softwareopengl
• matlab -nosoftwareopengl
• matlab -softwareopenglmesa
• matlab -noopengl

It will no longer be necessary to specify the renderer when these options are removed.

The Renderer property of figures will have no effect


Behavior change in future release

The Renderer and RendererMode properties of figures will have no effect in a future release. It will
no longer be necessary to change the renderer when these properties are disabled.

The FontSmoothing property will have no effect


Behavior change in future release

The FontSmoothing property for all types of axes, rulers, geographic scales, and text objects will
have no effect in a future release. Font smoothing will be enabled regardless of the value of the
property.

Some plot tools functions will redirect to the Figure Toolstrip and Property Inspector
Behavior change in future release

Calling these plot tools functions will open a configuration of the Figure Toolstrip and Property
Inspector. For more information, see the Version History section in the documentation for each
function.

• figurepalette
• plotbrowser
• propertyeditor
• propedit
• plottools
• showplottool
• plotedit

Currently, calling plot tools functions opens the Figure Palette, Plot Browser, and Property Editor.

4-31
R2022a

App Building

uistyle Function: Add icons and format text in table cells and tree
nodes
You can now create styles for table and tree UI components that specify an icon and a text interpreter
using the uistyle function.

• Specify the Icon property of the style object to add icons to table cells and tree nodes.
• Specify the IconAlignment property of the style object to modify where the icon appears in
relation to the text in table cells.
• Specify the Interpreter property of the style object to format text or add links using HTML
markup, or to add equations using TeX or LaTeX markup to table cells and tree nodes.
• Specify the HorizontalClipping property of the style object to control whether long text is
clipped on the left or the right in table cells and tree nodes.

Add a style to a UI component using the addStyle function.

For example, this code creates two styles, one that specifies an icon and one that specifies the text
interpreter as TeX, and applies the styles to columns of a table.

T = table(["x^2";"3x^3+1"],["Success";"Success"]);
fig = uifigure(Position=[500 500 300 160]);
t = uitable(fig,Position=[10 10 250 140],Data=T);

s1 = uistyle(Interpreter="tex");
s2 = uistyle(Icon="success",IconAlignment="right");
addStyle(t,s1,column=1)
addStyle(t,s2,column=2)

uitable Function: Rearrange columns of table UI components


interactively
You can specify the ability to interactively rearrange table columns in an app by using the
ColumnRearrangeable property. In a table UI component with the ColumnRearrangeable value
set to 'on', rearrange table columns in the app by clicking and dragging the column header.

In App Designer and apps created using the uifigure function, you can program an app to respond
when a user rearranges table columns by creating a DisplayDataChangedFcn callback function.

For more information, see Table Properties.

4-32
App Building

focus Function: Give keyboard focus to UI components


programmatically
Use the focus function to programmatically give focus to keyboard-focusable UI components. When
a UI component is focused, it is displayed with a blue focus ring, and app users can interact with the
component using the keyboard.

isInScrollView Function: Determine if a component is visible in a


scrollable container
Use the isInScrollView function to programmatically identify which components are visible given
the size and scroll location of a scrollable container. For example, you can determine which axes are
visible inside a scrollable figure window and then update the data only for those axes.

uigridlayout Function: Resize table, list box, and image UI components


to fit content
Grid layout managers with row heights or column widths of 'fit' now resize to fit the contents of
table, list box, and image UI components.

For example, when you create a table UI component inside a grid layout manager with a row height
or column width of 'fit', the height of the row or the width of the column resizes to fit the data in
the table.

fig = uifigure(Position=[680 558 300 170]);


gl = uigridlayout(fig);
gl.RowHeight = {'fit'};
gl.ColumnWidth = {'fit'};
tbl = uitable(gl,Data=rand(3));

Compatibility Considerations
In R2021b, grid layout managers with row heights or column widths of 'fit' scaled to a fixed size
when the row or column contained a table, list box, or image UI component.

• Table UI component — Row height and column width previously resized to 300 pixels.
• List box UI component — Row height previously resized to display at most four items. The exact
pixel value to display four items might vary depending on your settings.
• Image UI component — Row height and column width previously resized to 100 pixels.

4-33
R2022a

To display a table, list box, or image at its size in a release before R2022a, set the corresponding
elements of the RowHeight and ColumnWidth properties of the GridLayout object to their
respective fixed sizes.

Live Editor Tasks: Develop your own Live Editor tasks for use in live
scripts and functions
Live Editor tasks are simple point-and-click interfaces that can be embedded into a live script. Tasks
represent a series of MATLAB commands that are automatically generated as users explore
parameters.

You can develop your own custom Live Editor tasks by creating a subclass of the LiveTask base
class. Develop tasks to perform your own specific set of operations within a live script.

For more information, see Live Editor Task Development Overview.

Custom UI Components: Interactively create custom UI components in


App Designer
Use App Designer to interactively build your own UI components. Open a new blank custom UI
component in App Designer, lay out the component by combining existing MATLAB UI components or
graphics objects, and configure the component interface by creating public properties and public
callbacks that can be set when the component is used in an app.

Creating a custom UI component has these benefits:

• Modularization — Separate the display of large apps into independent, maintainable pieces.
• Reusability — Provide a convenient interface for adding and customizing similar components in
apps.
• Flexibility — Extend the appearance and behavior of existing UI components.

For more information, see Create a Simple Custom UI Component in App Designer.

App Designer: Modify tab focus order of components


You can view and modify the order in which components in your app receive keyboard focus when the
app user presses Tab. First, sort and filter the Component Browser by tab order by selecting Sort
& Filter by Tab Order from the drop-down list labeled View. The Component Browser lists only
the components in the app that can have focus, in the order of focus. You can then change the tab
order of the components by clicking and dragging the component names in the Component
Browser.

Alternatively, App Designer can automatically apply a left-to-right and then top-to-bottom tab focus
order for components in a container. Right-click the name of the container in the Component
Browser and select Apply Auto Tab Order.

4-34
App Building

App Designer: Specify error handling options and navigate from error
messages when debugging an app

To specify error handling options when debugging code in App Designer, configure the Run
button by clicking Run . You can choose to pause code execution when an error occurs, when a
warning occurs, or when a NaN or Inf value is returned.

Additionally, error messages in App Designer now contain links to relevant files and functions. Use
these links to navigate more easily to the documentation or to line numbers in your code when
debugging your apps.

App Designer: Manage image files in your app with an improved


workflow
When you specify image data for your app, such as the image source of an image component or the
icon of a button, select an image that is in the same folder as the MLAPP file or one of its subfolders.
The image will then load whenever the app is opened or run without it needing to be on the MATLAB
path. Alternatively, you can continue to use images in any location by adding the image files to the
MATLAB path.

App Designer: Convert components in a grid layout manager to use


pixel-based positioning
You can delete a grid layout manager and convert the components in the grid to use pixel-based
positioning. To use pixel-based positioning when you were previously using a grid layout manager,
right-click the container with the grid layout manager in the canvas, and select Remove Grid
Layout.

For more information, see Use Grid Layout Managers in App Designer.

App Designer: Use App Designer in most modern web browsers in


MATLAB Online
You can now use App Designer in MATLAB Online with the current versions of Mozilla® Firefox®,
Apple Safari, and Microsoft Edge®, in addition to Google Chrome®.

App Designer: Customize design environment layout


You can now customize the locations of the side panels and tabs in the App Designer design
environment.

To change the location of side panels such as the Component Library and the Component
Browser, click the panel header and drag it to a new location in the App Designer environment. To
change the location of your open tabs to display on the left, right, or bottom of the working area,
right-click the tab bar and select Tab Position.

Your changes to the design environment layout now persist even after you close and reopen App
Designer.

4-35
R2022a

Comparison Tool: Compare and merge app files in MATLAB Online


Compare and merge two versions of an app file in MATLAB Online using the Comparison Tool. To

open the Comparison Tool, click Compare in the Designer tab of the App Designer Toolstrip.

For more information, see Compare and Merge Apps.

Functionality being removed or changed


RearrangeableColumns property of table UI components is not recommended
Still runs

Starting in R2022a, using the RearrangeableColumns property to specify the ability to rearrange
columns in a table UI component is not recommended. Use the ColumnRearrangeable property
instead. The new property can have the same values as the old one.

There are no plans to remove support for the RearrangeableColumns property at this time.
However, the RearrangeableColumns property no longer appears in the list returned by calling the
get function on a table UI component.

UIAxes content is not displayed in App Designer Design View when the component is off
the canvas
Behavior change

When creating an app with a UIAxes component in App Designer, the UIAxes component content is
not displayed in Design View when the component is partially or fully off the canvas. Instead, the
UIAxes component is shown as a placeholder image. To see the content of the component, drag it
fully onto the canvas.

You can still modify properties of the UIAxes component when it is off the canvas, but you will not be
able to see a visual reflection of those changes in Design View until the component is dragged onto
the canvas.

4-36
App Building

ComponentContainer class assigns a parent before executing the setup method


Behavior change

When you create an instance of a custom UI component created using the


matlab.ui.componentcontainer.ComponentContainer class, the class now assigns the
component parent before executing the setup method. As a result, you might see unexpected
behavior if your setup method creates underlying UI components that can be parented to either a
figure created using the figure function or a figure created the uifigure function, such as panels,
tab groups, or button groups.

To update your class code, when you create such a component, specify the property value explicitly
for any property where the default value differs depending on the parent. For example, to create a
panel in your custom component that is sized using normalized units, specify Units as
"normalized" before setting the Position property.

ButtonDownFcn callback cannot be interactively assigned for custom UI components in App


Designer
Behavior change

Starting in R2022a, when you use a custom UI component in an app in App Designer, you cannot
interactively assign a ButtonDownFcn callback to the component. If you have an existing App
Designer app that contains a custom UI component with a ButtonDownFcn callback that you
assigned interactively, opening the app in R2022a disconnects the callback from the component. To
reassign the callback to the component, follow these steps:

1 If your app does not contain a StartupFcn callback, right-click the app node from the top of the
Component Browser hierarchy and select Callbacks > Add StartupFcn Callback.
2 In Code View, in the startupFcn function, add this code to assign the appropriate
ButtonDownFcn callback programmatically:

app.CustomUIComponentName.ButtonDownFcn = ...
@(src,event)CallbackFunctionName(app,event);

For example, if your app contains a custom UI component named app.IPAddress with a
ButtonDownFcn callback named IPAddressButtonDown, add this code to the startupFcn
function of your app:
app.IPAddress.ButtonDownFcn = @(src,event)IPAddressButtonDown(app,event);

4-37
R2022a

Performance
table Data Type Indexing: Improved performance when subscripting
with dot notation or multiple levels of indexing
table subscripting when using dot notation is significantly faster in R2022a than in R2021b. Also,
subscripting with multiple levels of indexing is faster.

• For example, when you use dot notation to refer to a table variable with 106 elements,
performance in R2022a is more than 4x faster than in R2021b.
function timingTest()
t = table(zeros(1e6,1), ones(1e6,1), nan(1e6,1));
indices = 1:1e5;

tic;
% Refer to variable using dot notation
for i = indices
x = t.Var1;
end
toc
end

The approximate execution times are:

R2021b: 1.55 s

R2022a: 0.36 s
• Similarly, when you use dot notation to assign an array to a table variable with 106 elements,
performance in R2022a is about 3x faster than in R2021b.
function timingTest()
t = table(zeros(1e6,1), ones(1e6,1), nan(1e6,1));
indices = 1:1e5;
x = randi(1e6,1e6,1);

tic;
% Assign to variable using dot notation
for i = indices
t.Var1 = x;
end
toc
end

The approximate execution times are:

R2021b: 2.15 s

R2022a: 0.72 s
• Also, when you use dot notation and parentheses to assign individual values to elements of a table
variable, performance in R2022a is more than 4x faster than in R2021b.
function timingTest()
t = table(zeros(1e6,1), ones(1e6,1), nan(1e6,1));
indices = randi(1e6,1,1e5);

4-38
Performance

tic;
% Assign to elements using dot notation and parentheses
for i = indices
t.Var1(i) = rand;
end
toc
end

The approximate execution times are:

R2021b: 5.08 s

R2022a: 1.20 s

The code was timed on a Windows 10, Intel Xeon CPU W-2133 @ 3.60 GHz test system by calling
each version of the timingTest function.

Classes: Improved performance for static methods, constant property


access, and package functions in scripts
The overhead times for these three actions when performed in scripts are reduced:

• Executing a package function


• Executing a static method
• Accessing a constant property

The overhead times for these actions in a script are now comparable with the times of execution in a
function, and the overheads are small enough that they can generally be ignored for performance
considerations.

This code performs each of these actions 1,000,000 times. (The code called in each loop is shown at
the end of this note.)

tic;
for j = 1:1000000
out = pkg1.pkg2.packageFunction(2);
end
toc;

tic;
for j = 1:1000000
out = MyClass.staticMethod(1);
end
toc;

tic;
for j = 1:1000000
out = pkg1.PackageClass.constantProperty;
end
toc;

The approximate times to complete each loop are:

R2021b:

4-39
R2022a

• Package function: 8.4 s


• Static method: 7.8 s
• Constant property access: 32 s

R2022a:

• Package function: 0.04 s (210x faster)


• Static method: 0.031 s (252x faster)
• Constant property access: 0.039 s (821x faster)

The code was timed on a Windows 10, Intel Xeon CPU W-2133 @ 3.60 GHz test system.

For use with the test code, PackageClass must be in folder +pkg1, and packageFunction must be
in folder +pkg1/+pkg2.

function out = packageFunction(in)


out = in;
end

classdef MyClass
methods (Static)
function out = staticMethod(in)
out = in;
end
end
end

classdef PackageClass
properties (Constant)
constantProperty = 3;
end
end

try Block: Improved performance when statements run error-free


The try block shows improved performance when the statements within the block run error-free. For
example, this code is approximately 6x faster than in the previous release:

function testTryPerformance
x = 1;
for i = 1:1e8
try
x = x * i;
catch
warning("Assignment was not successful.")
x = 1;
end
end
end

The approximate execution times are:

R2021b: 2.3 s

R2022a: 0.4 s

4-40
Performance

The code was timed on a Windows 10, Intel Xeon CPU E5-1650 v4 @ 3.60 GHz test system using the
timeit function:

timeit(@testTryPerformance)

Python Data Type Conversion: Improved performance when


converting between Python and MATLAB data types in out-of-process
mode
When you run Python code out of process, conversions between Python data types and MATLAB data
types show improved performance.

• The timingPythonList function converts a Python list object to a MATLAB cell array. This
code is about 118x faster than in the previous release:

function timingPythonList
l = py.list(['MATLAB','R',2022,'a','and',1.2,10^2, ...
2021,12,25,'2021','12','25','and', ...
2021,12,25,'2021','12','25']);
tic
ml = cell(l);
toc
end

The approximate execution times are:

R2021b: 1.18 s

R2022a: 0.01 s
• The timingPythonDict function converts a Python dictionary object to a MATLAB structure.
This code is about 57.9x faster than in the previous release:

function timingPythonDict
d = py.dict(pyargs('a',1,'b',2,'c',3,'d',4,'e',5, ...
'f',6,'g',7,'h',8,'i',9,'j',10,'k',11,'l',12, ...
'm',13,'n',14,'o',15,'p',16,'q',17,'r',18, ...
's',19,'t',20));
tic
ms = struct(d);
toc
end

The approximate execution times are:

R2021b: 0.521 s

R2022a: 0.009 s
• The timingDataTransfer function converts an array with 108 elements from a MATLAB double
array to a Python memoryview object and then back to a MATLAB double array. This code is
about 10x faster when converting from MATLAB to Python and approximately 11x faster when
converting from Python to MATLAB than in the previous release:

function timingDataTransfer
data = rand(100,10^6);
tic

4-41
R2022a

pydata = py.memoryview(data);
toc
tic
mdata = double(pydata);
toc
end

The approximate execution times for converting the MATLAB double array to the Python
memoryview object are:

R2021b: 4.0 s

R2022a: 0.4 s

The approximate execution times for converting the Python memoryview object to the MATLAB
double array are:

R2021b: 7.7 s

R2022a: 0.7 s

All of the code was timed on a Windows 10, Intel Core® i7-10510U CPU @ 1.80 GHz 2.30 GHz test
system by using Python 3.9 in out-of-process mode and calling the timingPythonList,
timingPythonDict, and timingDataTransfer functions.

MATLAB Engine API for Python: Improved performance with large


multidimensional arrays in Python
The Python multidimensional array component used by the MATLAB Engine API for Python shows
improved performance when:

1 Converting data from Python sequences to the data types defined by the matlab module
2 Transferring data back and forth between Python and MATLAB

In both cases, the improvement is noticeable when operating on arrays with at least 10 elements.
When transferring data back and forth, the improvement increases as the size of the array increases.

For example, this Python code measures the execution times of two operations:

1 Converting a Python array of size 108 to a MATLAB double array


2 Summing the elements of the MATLAB array using the MATLAB engine

The first operation is about 12x faster than in the previous release, and the second operation is about
110x faster than in the previous release:

import random
import time
import matlab.engine
eng = matlab.engine.start_matlab()

rand_array = [random.random() for i in range(10**8)]


s0 = time.perf_counter()
array_md = matlab.double(rand_array,size=(1, 10**8))
s1 = time.perf_counter() - s0
print('conversion to matlab.double(): {} seconds'.format(s1))

4-42
Performance

s0 = time.perf_counter()
sum_of_elems = eng.sum(array_md,1)
s1 = time.perf_counter() - s0
print('sum(): {} seconds'.format(s1))

The approximate execution times for the first operation are:

R2021b: 42 s

R2022a: 3.6 s

The approximate execution times for the second operation are:

R2021b: 210 s

R2022a: 1.9 s

The code was timed on a Windows 10, Intel Xeon CPU E5-1650 v4 @ 3.60 GHz test system by using
Python perf_counter() statements.

Matrix multiplication: Improved performance when multiplying sparse


and full matrices
Matrix multiplication shows improved performance when:

• One of the operands is a sparse matrix, and the other is a full matrix.
• The sparse operand has at least 50,000 nonzero elements.
• The full operand has at least 32 columns (or at least 32 rows when transposed).

The performance improvement arises from added support for multithreading in the operation, and
therefore the speedup improves as the matrix size and number of nonzero elements increase.

For example, multiplying a 102,400-by-102,400 sparse matrix with a 102,400-by-128 full matrix on a
machine with 6 physical cores is about 2.7x faster than in the previous release.

function timingSparseDenseMult
A = delsq(numgrid('S',322));
B = rand(size(A,2),128);
tic
for k = 1:10
C = A*B;
end
toc
end

The approximate execution times are:

R2021b: 0.8 s

R2022a: 0.3 s

The code was timed on a Windows 10, Intel Xeon CPU W-2133 @ 3.60 GHz test system by calling the
timingSparseDenseMult function.

4-43
R2022a

inv Function: Improved performance when inverting large triangular


matrices
The inv function shows improved performance when operating on large triangular matrices.

For example, inverting a 5,000-by-5,000 upper triangular matrix is about 3.7x faster than in the
previous release.

function timingInv
rng default
A = randn(5e3);
[~,R] = lu(A);

tic
Y = inv(R);
toc
end

The approximate execution times are:

R2021b: 1.1 s

R2022a: 0.3 s

The code was timed on a Windows 10, Intel Xeon CPU W-2133 @ 3.60 GHz test system by calling the
timingInv function.

sprand and sprandn Functions: Improved performance when


generating random sparse matrices
The sprand and sprandn functions show improved performance when generating random sparse
matrices if the number of nonzero elements in the output is larger than the number of rows.

For example, generating a 10,000-by-10,000 matrix with 10% density of nonzero elements is about
2.5x faster than in the previous release.

function timingSprand
n = 1e4;
d = 0.1;
rng default

tic
sprand(n,n,d);
toc
end

The approximate execution times are:

R2021b: 2.7 s

R2022a: 1.1 s

The code was timed on a Windows 10, Intel Xeon CPU W-2133 @ 3.60 GHz test system by calling the
timingSprand function.

4-44
Performance

fzero Function: Improved performance


The fzero function shows improved performance for objective functions specified as function
handles. This improvement is most noticeable for functions that take little time to evaluate. The
following example, which solves for 1e5 roots of a simple function, takes less than one third of the
time of the previous release:

N = 1e5;
rng default
levels = 1.5*rand(N,1);
out = zeros(N,1);
tic
for i = 1:N
out(i) = fzero(@(x)myfun(x,levels(i)),[0 2]);
end
toc

function u = myfun(x,lv)
u = x*sin(x) - lv;
end

The approximate execution times are:

R2021b: 5.83 s

R2022a: 1.66 s

The code was timed on a Windows 10, Intel Xeon CPU E5-1650 v4 @ 3.60 GHz test system by running
the above script.

diff Function: Improved performance with large number of elements


The diff function shows improved performance when operating on vectors with at least 105
elements or when operating along the first or second dimension of matrices and multidimensional
arrays with at least 5 x 105 elements.

For example, this code creates a double array with 2.5 x 107 elements and calculates differences
between adjacent elements. It is approximately 2.4x faster than in the previous release.

function timingDiff
rng default
N = 5000;
A = rand(N);

tic
for k = 1:40
D = diff(A);
end
toc
end

The approximate execution times are:

R2021b: 2.43 s

R2022a: 1.00 s

4-45
R2022a

The code was timed on a Windows 10, Intel Xeon CPU E5-1650 v4 @ 3.60 GHz test system by calling
the timingDiff function.

groupsummary, groupfilter, and grouptransform Functions: Improved


performance with small group size
Grouping functions groupsummary, groupfilter, and grouptransform show improved
performance, especially when the data count in each group is small.

For example, this code performs group summary computations on a matrix with 500 groups with a
count of 10 each. It is about 2.18x faster than in the previous release.
function timingGroupsummary
data = (1:5000)';
groups = repelem(1:length(data)/10,10)';
p = randperm(length(data));
data = data(p);
groups = groups(p);

tic
for k = 1:300
G = groupsummary(data,groups,"mean");
end
toc
end

The approximate execution times are:

R2021b: 2.14 s

R2022a: 0.98 s

The code was timed on a Windows 10, Intel Xeon CPU E5-1650 v4 @ 3.60 GHz test system by calling
the timingGroupsummary function.

nufftn Function: Improved performance with nonuniform sample


points or query points
The nufftn function shows improved performance when operating on either nonuniformly spaced
sample points or nonuniformly spaced query points.

For example, this code constructs a 32,768-by-3 matrix of nonuniform sample points t and calculates
the nonuniform discrete Fourier transform along each dimension of a 32-by-32-by-32 array. The code
is about 14.5x faster than in the previous release.
function timingSamplePoints
rng default
t = rand(32^3,3);
X = rand(32,32,32);
tic
Y = nufftn(X,t);
toc
end

The approximate execution times are:

4-46
Performance

R2021b: 2.76 s

R2022a: 0.19 s

The code was timed on a Windows 10, Intel Xeon CPU E5-1650 v4 @ 3.60 GHz test system by calling
the timingSamplePoints function.

As another example, this code constructs a 65,536-by-3 matrix of nonuniform query points f and
calculates the nonuniform discrete Fourier transform along each dimension of a 64-by-32-by-32 array.
The code is about 42.6x faster than in the previous release.

function timingQueryPoints
rng default
f = rand(64*32*32,3);
X = rand(64,32,32);
tic
Y = nufftn(X,[],f);
toc
end

The approximate execution times are:

R2021b: 4.26 s

R2022a: 0.10 s

The code was timed on a Windows 10, Intel Xeon CPU E5-1650 v4 @ 3.60 GHz test system by calling
the timingQueryPoints function.

Variables Editor and Live Editor: Improved speed of data display when
scrolling
For text and datetime data types in the Variables editor or in the generated output of the Live Editor,
the performance of vertical and horizontal scrolling is improved. Displayed data is optimized and the
rendering mechanism is faster, so data appears more quickly after scrolling in R2022a than in
previous releases.

For example, on a Windows 10, Intel Xeon CPU E5-1650 v4 @ 3.60 GHz test system, when you scroll
through a timetable with 3000 rows, the displayed data renders more quickly in R2022a than in
R2021b.

App Building: Improved performance when creating UI components


Creating UI components is faster in R2022a than in R2021b. As a result, apps start up faster when
you run them. This improvement is more noticeable for apps with many UI components.

For example, this code measures the time it takes to create 500 edit field components. The code is
about 1.25x faster than in the previous release.

function timingApp
fig = uifigure;
gl = uigridlayout(fig,Scrollable="on");
gl.RowHeight = repmat({'fit'},1,50);
gl.ColumnWidth = repmat({'fit'},1,10);

4-47
R2022a

drawnow

tic
for k = 1:500
uieditfield(gl);
end
drawnow
toc
end

The approximate execution times are:

R2021b: 7.5 s

R2022a: 6.0 s

The code was timed on a Windows 10, Intel Xeon CPU E5-1650 v4 @ 3.60 GHz test system by calling
the timingApp function.

uitable Function and UI Containers: Improved performance when


updating properties successively
Updating property values for certain UI components and containers is faster in R2022a than in
R2021b. This performance improvement applies to table UI components created using the uitable
function, UI containers created using the uipanel, uibuttongroup, uitab, and uitabgroup
functions, and custom UI components created using the ComponentContainer base class, when
these objects are parented to a figure created using the uifigure function.

For example, this code creates a table UI component and then updates the table cell values for 1000
cells. The code is about 5.2x faster than in the previous release.

function timingTableUpdates
fig = uifigure;
tbl = uitable(fig,"Data",rand(1000,15));
drawnow

tic
for k = 1:1000
tbl.Data(k,1) = 0;
end
drawnow
toc
end

The approximate execution times are:

R2021b: 2.6 s

R2022a: 0.5 s

The code was timed on a Windows 10, Intel Xeon CPU E5-1650 v4 @ 3.60 GHz test system by calling
the timingTableUpdates function.

4-48
Performance

UI Components: Improved performance when setting a property with


an unchanged value
Setting a property value of a UI component when the value is unchanged is faster in R2022a than in
R2021b. This speed increase leads to improved performance in apps that update many UI component
properties at once, even if not all property values have changed.

For example, this code sets the Value property of an edit field to the same value 1000 times. The
code is about 23x faster than in the previous release.

function timingValueSet
fig = uifigure;
ef = uieditfield(fig);
drawnow

tic
for k = 1:1000
ef.Value = "Text";
drawnow
end
toc
end

The approximate execution times are:

R2021b: 2.3 s

R2022a: 0.1 s

The code was timed on a Windows 10, Intel Xeon CPU E5-1650 v4 @ 3.60 GHz test system by calling
the timingValueSet function.

App Designer: Improved performance when loading apps with UIAxes


components off the canvas
In App Designer, apps with UIAxes components that lie partially or fully off the canvas in Design
View have these performance improvements:

• The app loads faster when you open it.


• The UIAxes components update faster in response to property edits.

The speed increase improves as the number of UIAxes components that lie off the canvas increases.

For example, create an app in App Designer using these steps:

1 Drag five UIAxes components onto the canvas.


2 Drag each of the axes components so that they lie partially off the canvas.
3 Save and close the app.

Reopen the app. The time it takes for App Designer to fully load the app is about 5.2x faster than in
the previous release.

The approximate load times are:

4-49
R2022a

R2021b: 10.5 s

R2022a: 2 s

Once the app is fully loaded, select a UIAxes component and change its title in the Property
Inspector. The property updates almost instantaneously. In the previous release, the property update
takes approximately 2 seconds.

These interactions were timed on a Windows 10, Intel Xeon CPU E5-1650 v4 @ 3.60 GHz test system.

Plots in Apps: Improved responsiveness for event-driven updates in


apps
Apps that involve continuous event-driven updates, such as animations implemented with a timer, are
more responsive to those events. To observe the improvement, the animation must be created in an
app or in a figure created with the uifigure function. For example, an app containing an animation
controlled by a timer object is more responsive when you call the timer’s start and stop methods.

This code creates an app using a timer object to plot a random number every 0.01 second. If you run
this app on a Windows 10, Intel Xeon CPU W-2133 @ 3.60 GHz test system, the animation responds
more quickly when you click the Start/Stop button than in the previous release.
function mytimerapp
uif = uifigure("CloseRequestFcn",@CloseRequest);
uibutton(uif,"State","Position",[235 59 100 22], ...
"ValueChangedFcn",@StateButtonChanged,"Text","Start/Stop");
ax = uiaxes(uif,"Position",[25 100 508 300],"XDir","reverse");

% Create initial plot line


p = plot(ax,0:60,zeros(1,61));

% Create timer object


RandTimer = timer(...
"ExecutionMode","fixedRate", ...
"Period",0.01, ...
"BusyMode","queue", ...
"TimerFcn",@RandTimerFcn);

% Timer function
function RandTimerFcn(~,~,~)
% Generate a random number and update plot line
ydata = p.YData;
ydata = circshift(ydata,1);
ydata(1) = rand;
p.YData = ydata;
end

% State button callback function


function StateButtonChanged(obj,~)
switch obj.Value
case 0
stop(RandTimer);
case 1
% If timer is not running, start it
if strcmp(RandTimer.Running,"off")
start(RandTimer);

4-50
Performance

end
end
end

% Figure close request function


function CloseRequest(~,~)
% Stop timer, then delete timer and figure
stop(RandTimer);
delete(RandTimer);
delete(uif);
end
end

Plots in Apps: Improved responsiveness of axes interactions within


apps
Responsiveness is improved for panning, rotating, and zooming into a region of interest within a plot.
To observe the improvement, the plot must be created in an app or in a figure created with the
uifigure function. The improvement is most noticeable for plots with large numbers of points, or
those that involve complex effects such as lighting, transparency, or texture maps. Systems equipped
with modern GPUs are more likely to show the improvement.

For example, create a 3-D scatter plot with 200,000 points. If you run this code on a Windows 10,
Intel Xeon CPU W-2133 @ 3.60 GHz test system with an NVIDIA Quadro® P620 GPU, and then drag to
rotate the plot, the rotation is smoother and responds more quickly to the drag gesture than in the
previous release.
z = linspace(0,4*pi,200000);
x = 2*cos(z) + rand(1,200000);
y = 2*sin(z) + rand(1,200000);
f = uifigure; a = axes(f);
scatter3(a,x,y,z,"filled")

4-51
R2022a

Plots in Apps: Improved responsiveness of axes interactions in plots


with two y-axes
Responsiveness is improved for panning, rotating, and zooming into a region of interest within a
UIAxes or Axes object in MATLAB Online that contains a chart created with yyaxis and a legend.
For such charts, updates are faster, and interactions are smoother in R2022a than in the previous
release.

For example, create a UIAxes object with two y-axes and a legend. If you run this code on a Windows
10, Intel Xeon CPU E5-1650 v4 @ 3.60 GHz test system, when you drag the cursor to pan the view of
a UIAxes object, the axes pan faster and track the cursor more closely in R2022a than in R2021b.

f = uifigure;
a = uiaxes(f);
plot(a,1:100,rand(1,100));
yyaxis(a,"right");
plot(a,1:100,linspace(1,10,100));
legend(a);

4-52
Performance

Plots in Apps: Faster animations in apps when multiple figures are


open
Animations show improved performance in apps when multiple figures are open. To observe the
improvement, all figures must be created with the uifigure function.

For example, this code opens 10 empty figures and an additional figure containing a plot. The plot
displays one marker that traces the path of a line at every iteration of a loop. The loop is about 6x
faster than in the previous release.

function movingmarker

% Open 10 empty figures


for n = 1:10
uifigure("Position",[10+n*3 10+n*3 200 200]);
end

% Create a figure and a plot with one marker


uif = uifigure;
x = linspace(0,10,200);
y = sin(x);
ax = axes(uif);
p = plot(ax,x,y,"-o","MarkerIndices",1);

% Move the marker along the sine wave


tic
for idx = 2:200
p.MarkerIndices = idx;
drawnow
end
toc
end

4-53
R2022a

The approximate execution times for the loop are:

R2021b: 32.6 s

R2022a: 5.4 s

The code was timed on a Windows 10, Intel Xeon CPU W-2133 @ 3.60 GHz test system by calling the
movingmarker function.

Property Inspector: Improved performance when opening for the first


time
The Property Inspector for a figure window shows improved performance when opening for the first
time in a MATLAB session. The delay between clicking the Property Inspector icon or calling
inspect and the inspector being ready is reduced. The improvement is most noticeable as the plot in
the figure window becomes more complex.

For example, open the Property Inspector for a plot of a 5-by-5 matrix by calling inspect. If you run
this code on a Windows 10, Intel Xeon CPU E5-1650 v4 @ 3.60 GHz test system, you can use the
Property Inspector sooner in R2022a than in R2021b.

r = rand(5,5);
p = plot(r);
inspect(p)

4-54
Software Development Tools

Software Development Tools

Projects: Reduce test runtime in continuous integration workflows


using the dependency cache
You can now specify where your project stores the dependency analysis results. In agile development
workflows that use Git and a continuous integration (CI) server, share the dependency cache file
(.graphml) to run an incremental dependency analysis and reduce the test suite runtime. See
Continuous Integration Using MATLAB Projects and Jenkins.

To set the project dependency cache file, on the Project tab, in the Environment section, click
Details. In Dependency cache file, browse to and specify a GraphML file. If the cache file does not
exist, the project creates it for you.

Alternatively, you can create and set the project dependency cache programmatically:

matlab.project.example.timesTable
proj = currentProject;
proj.DependencyCacheFile = "myProjectCacheFile"

Dependency Analyzer: Save dependency graph as image


You can now save the dependency analysis results as an image. See Export Dependency Analysis
Results.

Code Compatibility Analyzer App: Identify and address compatibility


issues against current version of MATLAB
The MATLAB Code Compatibility Report is now available as an app. You can access the Code
Compatibility Analyzer from the apps gallery in MATLAB or from the command line using
codeCompatabilityAnalyzer. For more information, see MATLAB Code Compatibility Analyzer.

Unit Testing Framework: Create test classes interactively using the


Current Folder browser
You can now create a test class using the Current Folder browser in MATLAB and MATLAB Online. To
create a new test class, right-click in the Current Folder browser and then select New > Test Class.

Unit Testing Framework: Create temporary folders that are


automatically removed
The matlab.unittest.TestCase class has a new method createTemporaryFolder that creates
a temporary folder for your tests. The lifecycle of the folder is tied to the test case. Once the test case
goes out of scope, the testing framework removes the folder.

4-55
R2022a

Unit Testing Framework: Generate DOCX, HTML, and PDF reports after
test execution
The matlab.unittest.TestResult class has three new methods that enable you to generate
various test reports from test results. You can run your tests and collect the test results, and then
generate test reports from part or all of your results:

• To generate a DOCX report from the test results, use the generateDOCXReport method.
• To generate an HTML report from the test results, use the generateHTMLReport method.
• To generate a PDF report from the test results, use the generatePDFReport method.

With this feature, you are no longer required to run tests using a TestReportPlugin instance. For
example, run your tests and then generate an HTML report from the test results. Save the report as
report.html in a folder named myResults.

suite = testsuite("MyTestClass");
runner = testrunner;
results = run(runner,suite);
generateHTMLReport(results,"myResults",MainFile="report.html")

Unit Testing Framework: Debug uncaught errors in tests


Starting in R2022a, when a test runner with a StopOnFailuresPlugin instance encounters an
uncaught error, MATLAB enters debug mode at the source of the error and lets you use debugging
commands to investigate the cause of the error. In previous releases, while the plugin stops the test
run to report the error, debugging capabilities are limited because the error disrupts the stack.

Unit Testing Framework: Collect statement and function coverage


metrics for your source code
Starting in R2022a, when you generate an HTML code coverage report using the CoverageReport
format, the report displays statement and function coverage metrics:

• Use statement coverage to see whether every MATLAB statement in your source code is executed
at least once.
• Use function coverage to see whether every function in your source code is called at least once.

In previous releases, you can generate only line coverage metrics for your source code. Compared to
line coverage, statement and function coverage provide a more detailed analysis of the source code
covered by the tests.

Functionality being removed or changed


pack function will be removed in a future release
Warns

The pack function will be removed in a future release. There is no replacement for this function
because you do not need to use it on a 64-bit system. For more information about strategies for
reducing memory usage, see Strategies for Efficient Use of Memory and Resolve “Out of Memory”
Errors.

4-56
Software Development Tools

matlab.unittest.TestSuite.fromFolder includes tests from package folders when creating a


test suite
Behavior change

Starting in R2022a, the matlab.unittest.TestSuite.fromFolder method treats folders and


packages the same way, and includes tests defined within package folders when creating a test suite.
For example, suite =
matlab.unittest.TestSuite.fromFolder(pwd,IncludingSubfolders=true) creates a suite
from all the test files in the current folder and any of its subfolders, including package folders. In
previous releases, the method ignores any tests defined in a package folder and its subfolders.

This behavior change also applies to the testsuite, runtests, and runperf functions when they
operate on a folder containing tests. With the consistent treatment of folders and packages, creating
a suite from all test files within a folder and its subfolders becomes more convenient and independent
of the folder structure.

To exclude tests defined within packages, filter the suite being constructed or returned by
fromFolder. For example, create a filtered test suite comprising tests whose names do not include
any dots (that is, do not refer to any packages).

import matlab.unittest.TestSuite
import matlab.unittest.selectors.HasName
import matlab.unittest.constraints.ContainsSubstring
suite = TestSuite.fromFolder(pwd,HasName(~ContainsSubstring(".")), ...
IncludingSubfolders=true);

builddocsearchdb creates searchable database with new name


Behavior change

When building a searchable documentation database for custom toolboxes, the builddocsearchdb
function now creates the subfolder helpsearch-v4 to contain the search database files. Previously,
builddocsearchdb created a subfolder named helpsearch-v3.

To ensure the documentation for the custom toolbox is searchable in R2022a, run
builddocsearchdb against your help files using MATLAB R2022a. Maintain the helpsearch-v4
subfolder containing the search database files created in R2022a and the helpsearch-v3 subfolder
containing the search database files created in previous releases side by side. Then, when you run
any MATLAB release, the Help browser automatically uses the appropriate database for searching
your documentation.

4-57
R2022a

External Language Interfaces

C++ Interface: Array size help text for functions and methods
If a function or method takes a clib or MATLAB array, the generated help text displays size
information for the argument. For more information, see Array Size Help for Functions and Methods.

C Interface: Build third-party C library interface using


clibgen.generateLibraryDefinition
Create interfaces for libraries with C files that are built with C compilers using
clibgen.generateLibraryDefinition. Use this function to get the benefits of publishing an
interface as described in Build MATLAB Interface to C++ Library instead of calling the
loadlibrary function described in Call C from MATLAB.

For information about using clibgen.generateLibraryDefinition with C files, see Files in


Your Library under the Tips section. To build an interface to C libraries, use the CLinkage name-
value argument.

C++ Interface: Support for C++ language features


The C++ interface supports these additional C++ language features.

• std::complex support for complex scalars and arrays for fundamental types of double, float,
int8, uint8, int16, uint16, int32, uint32, int64, and uint64. For information about
mapping these types to MATLAB data, see Numeric Types.
• If the size of a 1-D array parameter is not specified, you can represent the size in MATLAB using
multiple dimensions. For example, the input to this function is a 2-D array mat of size len-by-
typeSz.

void readMatrix2DArr(int const [] mat, size_t len, size_t typeSz)

You can specify the SHAPE of the argument as ["len","typeSz"]. For more information, see
Define Missing SHAPE Parameter.
• std::vector as data member.

C++ Interface: Publisher options


The C++ interface supports these build configuration features.

• Specify compiler and linker flags used to build an interface. Use the AdditionalCompilerFlags
or AdditionalLinkerFlags name-value arguments in
clibgen.generateLibraryDefinition or clibgen.buildInterface to pass flags to the
compiler and linker. These functions do not validate the flags. The publisher needs to know how
the flags affect the build process. For more information, see Build C++ Library Interface and
Review Contents.
• Build an interface using a specific compiler standard. For example, to build a library defined by
A.hpp with C++17, type:
clibgen.generateLibraryDefinition("A.hpp",AdditionalCompilerFlags="-std=c++17")

4-58
External Language Interfaces

For more information, see Specify C++ Compiler Standard.


• Include static libraries with .a file extension on Linux and macOS platforms, and on Windows if
the library is compiled with a supported MinGW compiler. To include a static library, use the
Libraries name-value argument in clibgen.generateLibraryDefinition or
clibgen.buildInterface.

Call MATLAB from C++: Generate C++ code Interface for MATLAB
Packages, Classes, and Functions
The matlab.engine.typedinterface.generateCPP creates a C++ header file from MATLAB
packages, classes, and functions. For more information, see What is Strongly Typed Interface for C+
+?.

MATLAB Data Array API: matlab::data::Array support for row-major


order
The MATLAB data array API supports iterating through the data of a matlab::data::Array in
either row-major or column-major order. For information about specifying the layout when creating
an array, see the inputLayout parameter for createArray. For information about iterating
through an array, see matlab::data::ColumnMajor,
matlab::data::ColumnMajorIterator<T>, matlab::data::RowMajor, and
matlab::data::RowMajorIterator<T>.

MEX Functions: UTF-8 system encoding on Windows platforms


MATLAB now uses UTF-8 as its system encoding on Windows, completing the adoption of Unicode
across all supported platforms. System calls made from within a MEX file take and return UTF-8
encoded strings. If your MEX file contains code or links to third-party libraries that assume a different
system encoding, then you might see garbled text and thus need to update the code to be Unicode
compliant.

Python: Use Name=Value syntax to pass keyword arguments to


Python functions
You can use MATLAB Name=Value syntax as an alternative to the pyargs function to pass keyword
arguments to Python functions. However, do not mix Name=Value arguments with the use of the
pyargs function.

MATLAB does not support Name,Value syntax for passing keyword arguments.

Python: Convert Python list and tuple types to MATLAB types


You can convert Python list and tuple types using MATLAB string and numeric converters. For
details, see the py.list and py.tuple entry in the Explicitly Convert Python Types to MATLAB
Types table. For examples, see Use Python list Variables in MATLAB and Use Python tuple
Variables in MATLAB.

Conversion functions might not work on lists or tuples that contain elements which cannot be
converted to the requested type:

4-59
R2022a

double(py.list({3.0, 'MATLAB'}))

Error using py.list/double


Conversion of Python element at position 2 to type 'double' failed. All
Python elements must be convertible as scalar to the requested type.

Related documentation

For the related documentation, see Error Converting Elements of list or tuple.

Perl 5.34.0: MATLAB support on Windows


As of R2022a, MATLAB on Windows ships with an updated version of Perl, version 5.34.0.

Compatibility Considerations
If you use the perl command on Windows platforms, see https://www.perl.org/ for information about
using this version of the Perl programming language.

Compilers: Support for Microsoft Visual Studio 2022


As of R2021b Update 3, MATLAB supports Microsoft Visual Studio 2022 for building C and C++
interfaces, MEX files, and standalone MATLAB engine and MAT-file applications.

Functionality being removed or changed


Python: Version 3.7 is no longer supported
Errors

Support for Python version 3.7 is discontinued. For continued support for your applications, upgrade
to a supported version of Python. For supported version information, see Versions of Python
Compatible with MATLAB Products by Release.

MEX file macro FORTRAN_COMPLEX_FUNCTIONS_RETURN_VOID has been removed


Behavior change

For MEX files built in R2021b and earlier, MATLAB provided a macro,
FORTRAN_COMPLEX_FUNCTIONS_RETURN_VOID, to handle platform-dependent calling syntax
differences for passing complex numbers to Fortran BLAS and LAPACK functions. As of R2022a, you
no longer need a different calling syntax on different platforms, and the macro for handling this
difference has been removed.

To update your code, replace statements such as these using


FORTRAN_COMPLEX_FUNCTIONS_RETURN_VOID:
/* Call BLAS function */
/* Use a different call syntax on different platforms */
#ifdef FORTRAN_COMPLEX_FUNCTIONS_RETURN_VOID
zdotu(&result, &nElements, zinA, &incx, zinB, &incy);
#else
result = zdotu(&nElements, zinA, &incx, zinB, &incy);
#endif

with:

4-60
External Language Interfaces

/* Call BLAS function */


zdotu(&result, &nElements, zinA, &incx, zinB, &incy);

See dotProductComplex.c.

NET.addAssembly no longer removes leading spaces for Windows drive letter paths
Behavior change

Before R2022a, on Windows platforms, the NET.addAssembly function removed leading spaces in
paths specifying the drive letter. If the full path to your assembly is invalid with leading spaces, then
remove the spaces before calling NET.addAssembly.

4-61
5

R2021b

Version: 9.11

New Features

Bug Fixes

Compatibility Considerations
R2021b

Environment

Editor Selection: Select and edit a rectangular area of code


In the Editor, you now can select a rectangular area in your code (also known as column selection or
block edit) by pressing the Alt key while making a selection with the mouse. On macOS systems, use
the Option key instead. Selecting and editing a rectangular area of code is useful if you want to copy
or delete several columns of data, or if you want to edit multiple lines at one time.

For example, select the second column of data in A.

Type 0 to set all the selected values to 0.

Editor Display: Zoom in and out in the Editor

To zoom in or out in the Editor, go to the View tab, and in the Zoom section, select the Zoom In

or Zoom Out button. As you zoom, MATLAB displays the current scale in the bottom-right corner
of the Editor. You also can hold the Ctrl key and move the scroll wheel, or press Ctrl+Plus and Ctrl
+Minus. On macOS systems, use the Command key and move the scroll wheel, or press Command
+Shift+Plus and Command+Shift+Minus.

To return to the default scale, in the View tab Zoom section, select Reset Zoom. You also can
press Ctrl+Alt+0 (Command+Alt+0 on macOS).

Editor Code: Show code suggestions and completions automatically


Starting in R2021b, when you write commands in the Editor, MATLAB automatically displays
contextual hints for arguments, property values, and alternative syntaxes. In previous releases,
MATLAB only completes names in the Editor after a Tab key press.

For example, if you want to use the size function, MATLAB automatically displays the syntax
information to help you write the command as you type.

5-2
Environment

MATLAB also automatically suggests and completes the names of functions, models, MATLAB objects,
files, folders, variables, structures, graphics properties, parameters, and options.

You can disable automatic completions in the Editor and Live Editor by having MATLAB suggest and
complete names only after you press the Tab key. To do so, on the View tab, in the Display section,
click the Automatic Completions button off. You also can go to the Home tab, and in the
Environment section, click Preferences. Then, select Editor/Debugger > Automatic
Completions and in the Suggestions and completions section, select Show on tab.

For more information, see Check Syntax as You Type.

Editor Debugging: Diagnose problems in scripts and functions using


inline debugging controls and a breadcrumb-style function call stack
When debugging code in the Editor, you now can diagnose problems using inline debugging controls.
For example, to run to a specific line of code and then pause, click the button to the left of the line.

To step into a file, click the button directly to the left of the function you want to step into. After
stepping in, click the button at the top of the file to run the rest of the called function, leave the
called function, and then pause.

By default, the button only appears for user-defined functions and scripts. To show the button for
MathWorks functions as well, on the Home tab, in the Environment section, click Preferences.
Then, select MATLAB > Editor/Debugger, and in the Debugging in the Live Editor section, clear
the Only show Step in button for user-defined functions option.

When you step into a called function or file, the Editor displays an improved breadcrumb-style list of
the functions MATLAB executed before pausing at the current line (also called the function call
stack). The function call stack is shown at the top of the file and displays the functions in order,
starting on the left with the first called script or function, and ending on the right with the current
script or function in which MATLAB is paused.

5-3
R2021b

For more information, see Debug MATLAB Code Files.

Editor Refactoring: Automatically convert selected code to a function


Break large scripts or functions into smaller pieces by converting selected code into functions in files
or local functions. With one or more lines of code selected, on the Editor tab, in the Code section,
click the Refactor button, and then select from the available options. MATLAB creates a function
with the selected code and replaces the original code with a call to the newly created function.

Editor Code: Automatically complete block endings, match delimiters,


and wrap comments while editing code
MATLAB now automatically completes parentheses and quotes when you enter code in the Editor. For
example, if you type an open parenthesis in the Editor, MATLAB automatically adds the closing
parenthesis. MATLAB also automatically completes comments, character vectors, strings, and
parentheses split across two lines.

You also can have MATLAB automatically complete block endings. To do so, on the Home tab, in the
Environment section, click Preferences. Select Editor/Debugger > Automatic Completions
and in the Autocoding options section, select one or more of the Autocomplete block endings
options.

To undo an automatic code completion, press Ctrl+Z or the Undo button. To disable automatic
code completions, in the Editor/Debugger > Automatic Completions preferences, clear one or
more of the options in the Autocoding options section.

Editor Sections: Create sections with an improved appearance


Starting in R2021b, sections in the Editor have an improved appearance. To create a new section, go
to the Editor tab and in the Section section, click the Section Break button. The new section is
highlighted with a blue border, indicating that it is selected.

5-4
Environment

To maximize the space available for editing code in the Editor, you can hide the Run to Here and Code
Folding margins. This minimizes the gray area to the left of your code. To hide the two margins, right-
click the gray area to the left of your code and clear the Show Run to Here Margin and Show Code
Folding Margin options.

As part of this change, the options for changing the appearance of code sections in the Editor have
been removed. These options were previously available in the MATLAB > Colors > Programming
Tools preferences, in the Section display options section.

For more information about sections in the Editor, see Create and Run Sections in Code.

Editor Code: Change the case of text and code


You can change the case of selected text or code in the Editor from all uppercase to lowercase, or
vice versa. To change the case, select the text, right-click, and select Change Case. You also can
press Ctrl+Shift+A to change the case. If the text contains both uppercase and lowercase text,
MATLAB changes the case to all uppercase.

Editor Bookmarks: Maintain bookmarks after closing a file


Starting in R2021b, MATLAB maintains all bookmarks after you close a file in the Editor. In previous
releases, MATLAB does not maintain bookmarks after closing a file.

For more information, see Go To Location in File.

Live Editor Controls: Set default values for sliders, drop-down lists,
check boxes, and edit fields
You can set the default values for sliders, drop-down lists, check boxes, and edit fields in your live
scripts. To set the default value for a control, right-click the control and select Configure Control.
Then, in the Defaults section, specify a default value by entering the value or by selecting a
workspace variable from the list. The list shows only valid variables for the control. For drop-down
lists, select the default value from the list of items.

To restore the default value for a control, right-click the control and select Restore Default Value.

5-5
R2021b

For more information, see Add Interactive Controls to a Live Script.

Live Editor Animations: Export animations to movies or animated GIFs

Export animations to movies or animated GIFs using the new Export Animation button in the Live
Editor animation playback controls. The Export Animation button is not supported for animations
generated by the movie function.

For example, this code animates a line growing as it accumulates 2000 data points in the Live Editor.

When the animation is done playing, playback controls, including the new Export Animation
button, display within the figure window.
h = animatedline;
axis([0 4*pi -1 1])
x = linspace(0,4*pi,2000);

for k = 1:length(x)
y = sin(x(k));
addpoints(h,x(k),y);
drawnow
end

For more information about creating animations, see Animation Techniques.

Live Editor Figures: Interact with real MATLAB figures and resize them
with improved layouts
Live Editor output figures are now real MATLAB figures with most of the interaction capabilities of
standalone MATLAB figures. In addition, when you resize a figure in the Live Editor, the font sizes
and spacing between elements in the figure now automatically adjust to provide the best possible
presentation for the new size.

5-6
Environment

Live Editor: Improved performance when saving live scripts or


functions
Saving live scripts and live functions in the Live Editor is faster in R2021b than in R2021a. The
improvement is most noticeable when you save live functions with more than 1000 lines of code and
live scripts with fewer than 100 lines of code.

For example, on a Windows 10, Intel Xeon E5-1650 CPU @ 3.60 GHz test system, saving an example
live function containing 4000 lines of code takes approximately 2.05 seconds in R2021b. In R2021a,
saving the same live function takes approximately 2.57 seconds.

Comparison Tool: Compare and merge text files with improved


usability, appearance, and syntax highlighting
In R2021b, the comparison tool uses MATLAB Editor syntax highlighting. Text changes and merge
choices are now easier to understand. Changes are highlighted with strong colors. Modified lines are

highlighted and flagged with the comparison icons , , or . Merging line by line is

straightforward, and merge choices are flagged with the merge content icon .

5-7
R2021b

Compatibility Considerations
Starting in R2021b, you no longer can save the comparison report as HTML or specify whether to
show only the differences or the entire files.

Importing Preferences from Previous Releases: MATLAB checks for


preferences from R2019b or newer
During start up, MATLAB checks for a preferences folder that matches the current release. If that
folder is not found, MATLAB checks for preferences folders going back as far as R2019b. Releases
before R2021b continue to check for up to three previous releases.

MATLAB Release Previous Release Preferences Folders


R2021b R2021a, R2020b, R2020a, R2019b
R2021a R2020b, R2020a, R2019b
R2020b R2020a, R2019b, R2019a

Display language: MATLAB uses Windows display language settings


for selecting desktop language
MATLAB uses the Windows display language settings on Windows 10 to control the MATLAB
desktop language. The display language you select on Windows changes the default language used by
Windows features like settings and file explorer.

Prior to R2021b, MATLAB controlled the desktop language using the Windows locale setting which is
managed in the Region settings.

For information about Windows locale settings in MATLAB, see Set Locale on Microsoft Windows
Platforms.

For information about managing display language settings, refer to your Windows 10 documentation.

Functionality being removed or changed


Increment Value and Run Section tool has been removed

The Increment Value and Run Section tool previously available in the Editor has been removed.

To increment a numeric value within a section, use controls in the Live Editor. For example, this code
calculates the factorial of the variable x.

x = 5;
y = factorial(x)

y =
120

To interactively change the value of x, in a live script, replace the value 5 with a numeric slider. By
default, MATLAB reruns the current section when the value of the slider changes.

5-8
Environment

For more information, see Add Interactive Controls to a Live Script.

5-9
R2021b

Language and Programming

cast Function: Consistent output for all syntaxes with the same data
type conversion
The cast function now returns consistent output for all syntaxes with the same data type conversion.

For example, starting in R2021b, both b = cast(fi(1),'like',sym(1)) and b =


cast(fi(1),'sym') return b = 1 of the sym data type. In previous releases, b =
cast(fi(1),'like',sym(1)) returns b = 1 of the sym data type, but b = cast(fi(1),'sym')
throws an error.

Run Code in the Background: Use parallel language to run code


asynchronously
You can now run code in the background using backgroundPool. When you run code in the
background, you can:

• Run other MATLAB code at the same time as a long running calculation
• Create more responsive user interfaces

Use the background pool with the following parallel language:

• parfeval and related functionality such as afterEach and afterAll


• parallel.pool.DataQueue and related functionality such as afterEach
• parallel.pool.PollableDataQueue and related functionality such as poll

For more information, see Background Processing.

Portable Parallel Code: Share parallel code and seamlessly run in


parallel
You can now run parallel code even if you do not have Parallel Computing Toolbox. When you run
portable parallel code without Parallel Computing Toolbox, you run the code in serial on your
machine. When you run this code with Parallel Computing Toolbox, you can automatically scale up
and run the code in parallel on your local machine, on a remote cluster, or in the cloud.

The following parallel language features are available for prototyping:

• parfeval — Seamlessly run multiple functions at once (since R2021b)


• parfor — Seamlessly run for-loops in parallel (since R2008a)

For more information, see Run Parallel Language in MATLAB.

5-10
Language and Programming

Compact Display for Classes: Customize display of information about


classes when space is limited
Use the matlab.mixin.CustomCompactDisplayProvider class to customize how information
about your classes is displayed in a container variable—such as a struct, cell array, or table—where
space is limited. Options for customization include:

• Displaying partial sets of data


• Adding annotations
• Controlling how and when class names are displayed

For example, an enumeration class of the days of the week, WeekDays, can be customized so that
when arrays of WeekDays members cannot be fully displayed, MATLAB displays the size, the class,
and an annotation. When the width of the Command Window is large enough, the full array is shown:

myStruc =

struct with fields:

prop1: [Monday Wednesday Friday Saturday Sunday]

When the Command Window is not wide enough to display the full array, the size, the class, and an
annotation are shown:

myStruc =

struct with fields:

prop1: 1x5 Weekdays (Enum of days of week)

Class Aliasing: Create aliases for renamed classes to maintain


backward compatibility
When you need to change a class name, you can create an alias to preserve compatibility with code
written before the name change. The matlab.alias.AliasFileManager class provides an API for
defining and implementing aliases. Once you define an alias, you can use the alias anywhere you use
the class name. Aliases maintain backward compatibility when reloading objects with the old name
into a MATLAB version that uses the new name, as well as forward compatibility when loading
objects saved in a newer version into an older version that predates the definition of the alias.
MATLAB substitutes the new class name whenever it encounters the old name.

Modular Indexing: Customize class indexing operations individually


using new superclasses
To customize how indexing operations behave with your class in previous versions of MATLAB, you
need to overload the subsref and subsasgn methods. Doing so requires implementing code for all
indexing reference and assignment operations, including parentheses, dot, and brace operations,
even if you want to change only one type of indexing operation.

Starting in R2021b, you can inherit from three new superclasses to customize parentheses, dot, and
brace indexing operations individually:

5-11
R2021b

• matlab.mixin.indexing.RedefinesParen – Customize parentheses reference, assignment,


and deletion operations.
• matlab.mixin.indexing.RedefinesDot – Customize dot reference and assignment
operations.
• matlab.mixin.indexing.RedefinesBrace – Customize brace reference and assignment
operations.

You can inherit from one or more of these classes without affecting how the other indexing operations
work. These classes also enable you to forward levels of indexing in compound statements to other
MATLAB values. For example, your class can implement custom parentheses indexing for the first
level of a compound reference and then allow MATLAB to apply the other levels to an object
contained by your class.

Scalar Classes: Inherit from the matlab.mixin.Scalar superclass to


ensure instances behave as scalars
Instances of classes that inherit from matlab.mixin.Scalar must behave as scalars. You cannot
form arrays of instances of such a class, including empty arrays, and you cannot concatenate
instances. This class is useful for cases in which concatenation does not make sense, like a dictionary
or other container class in which parentheses indexing is customized to access data in the class, not
to form or access arrays.

startat Function: Time zone information in datetime objects now


supported
The startat function now recognizes time zone and daylight savings time information of datetime
inputs.

Functionality being removed or changed


newclass input argument of the syntax cast(A,newclass) is now case-sensitive
Behavior change

Starting in R2021b, the newclass input argument of the syntax cast(A,newclass) is case-
sensitive. You must specify newclass as a character vector or a string of lowercase letters that
represents the new data type.

For example, to convert a double value to the int8 data type, you must use b =
cast(1.234,'int8'). The function syntax b = cast(1.234,'Int8') now throws an error.

Defining classes and packages: Using schema.m will not be supported in a future release
Still runs

Support for classes and packages defined using schema.m files will be removed in a future release.
Replace existing schema-based classes with classes defined using the classdef keyword.

InexactCaseMatch and InexactCaseMatchForExtension Errors: These errors are replaced by


UndefinedFunction error
Behavior change

5-12
Language and Programming

The InexactCaseMatch and InexactCaseMatchForExtension errors have been removed and


MATLAB throws an UndefinedFunction error instead. This change does not generate new errors in
code that did not previously throw an error.

5-13
R2021b

Data Analysis

Compute by Group Live Editor Task: Interactively summarize,


transform, or filter groups of data
Use the Compute by Group Live Editor task to interactively compute statistics, transform data, or
filter data by group. To open the task in the Live Editor, use the Task menu on the Live Editor tab.

Normalize Data Live Editor Task: Interactively center and scale data
Use the Normalize Data Live Editor task to visualize the effects of centering and scaling data using
various methods, such as the z-score. To open the task in the Live Editor, use the Task menu on the
Live Editor tab.

Clean Missing Data Live Editor Task: Define missing values


When using the Clean Missing Data Live Editor task, you can now define missing value indicators
that are different from the standard MATLAB missing values.

trenddecomp Function: Find trends in data


Use the trenddecomp function to additively decompose data into a long-term trend and seasonal
trends.

min and max Functions: Specify the comparison method for


determining minimum and maximum values
The min and max functions now accept the 'ComparisonMethod' parameter, which specifies a
method for determining the minimum and maximum values of the input while preserving the sign in
the output.

uniquetol Function: Options to control element selection and preserve


range of data
uniquetol has two new options to control behavior:

• occurrence argument: Specify whether the algorithm begins with the highest or lowest elements
in the input data. This can change which element, among several that are within tolerance of each
other, is selected as being unique. The default is to begin with the lowest elements.
• 'PreserveRange' name-value argument: Specify whether the range of the output data should be
the same as the input data.

Data Preprocessing Functions: Specify table variable as sample points


vector
When you operate on table input data, the following functions now allow you to specify which variable
in the table to use with the 'SamplePoints' parameter:

5-14
Data Analysis

• fillmissing
• filloutliers
• ischange
• islocalmax
• islocalmin
• isoutlier
• rmoutliers
• smoothdata

dateshift Function: Shift to next occurrence of weekday or weekend


day
You can now use the 'weekday' and 'weekend' arguments to shift the elements of a datetime
array when using the dateshift function.

• To shift to the next occurrence of a weekday on or after each element of the input datetime
array, use 'weekday'.
• To shift to the next occurrence of a weekend day on or after each element of the input datetime
array, use 'weekend'.

isbetween Function: Support for open, closed, and half open intervals
The isbetween function now supports open, closed, and half open intervals. In previous releases,
isbetween supports only closed intervals.

isregular Function: Support for datetime and duration data types


You can now use the isregular function to determine if a timetable, datetime vector, or duration
vector is regular. In previous releases, you can use isregular only on a timetable.

istabular Function: Determine if input is a table or timetable


To determine if an input variable is either a table or a timetable, use the istabular function.

Using this function is equivalent to using the statement tf = istable(A) || istimetable(A),


but is more convenient.

retime and synchronize Functions: Median and mode methods


supported
When you synchronize data in timetables, you can now specify 'median' and 'mode' as aggregation
functions. For more information, see retime and synchronize.

timeofday Function: Return the date as the second output argument


You can now return the dates from the elements of a datetime array as the second output argument
from the timeofday function.

5-15
R2021b

timeseries2timetable Function: Convert timeseries objects to


timetables
To convert timeseries objects to timetables, use the timeseries2timetable function.

Functionality being removed or changed


isordinal accepts input argument that has any data type
Behavior change

The isordinal function now accepts an input argument that has any data type. In previous releases,
isordinal threw an error if the input argument was not a categorical array.

Synchronize Timetables Live Editor task synchronizes an unlimited number of timetables


Behavior change

The Synchronize Timetables Live Editor task can now synchronize an unlimited number of
timetables. In previous releases, the task can synchronize no more than five timetables.

timeseries2timetable replaces ts2timetable


Behavior change

The timeseries2timetable function replaces the ts2timetable function, although


ts2timetable is still provided. The two functions are synonyms. In R2021a, MATLAB provides
ts2timetable only.

5-16
Data Import and Export

Data Import and Export

sftp Function: Connect to SFTP servers


MATLAB can connect to SFTP servers for encrypted data transfers. Create an SFTP connection object
using the sftp function to read data from an SFTP server.

Datastores: Specify FileSet objects as data locations for some


datastores
Some datastore functions and objects accept FileSet objects as the locations of files to include in
the datastore. FileSet objects provide increased performance compared to file paths or DsFileSet
objects. This functionality is supported by these functions:

• tabularTextDatastore
• spreadsheetDatastore
• fileDatastore
• keyValueDatastore
• tallDatastore
• parquetDatastore
• imageDatastore
• signalDatastore (Signal Processing Toolbox)
• audioDatastore (Audio Toolbox)
• mdfDatastore (Vehicle Network Toolbox)

Table Import: Read tables from HTML and Microsoft Word documents
The readtable function now supports reading tables from HTML and Microsoft Word files.

To customize import options for HTML and Microsoft Word files, use htmlImportOptions and
wordDocumentImportOptions, respectively. To automatically detect import options from files, use
the detectImportOptions function.

HDF5 Interface: Use new functionality in support of HDF5 1.10.7


Use these new capabilities of the MATLAB HDF5 function interfaces:

• Single-Writer/Multiple-Reader (SWMR) — Write data to an HDF5 file in one process while you
concurrently read from the file in one or more reader processes. For more information, see Read
and Write Data Concurrently Using Single-Writer/Multiple-Reader (SWMR).
• Virtual Dataset (VDS) — Use the MATLAB low-level interface to access data stored across multiple
HDF5 files, including files in remote locations, as a single, unified HDF5 dataset. You can also read
data stored in Virtual Datasets using the HDF5 high-level interface. For more information, see
Work with HDF5 Virtual Datasets (VDS).
• Metadata Cache Fine-Tuning — Improve performance by controlling the parameters of the
metadata cache, such as limiting the number of file reading attempts.

5-17
R2021b

• Partial Edge Chunk — Control whether to filter partial edge chunks.

NetCDF Interface: Read and write NC_STRING data


You can now use the existing high-level and low-level functions to read NC_STRING data from
NetCDF-4 files and write text data as type NC_STRING.

For more information on data type mapping between the NetCDF API and MATLAB, see Map NetCDF
API Syntax to MATLAB Syntax.

Scientific File Format Libraries: HDF5 and NetCDF libraries are


upgraded
The HDF5 library is upgraded to version 1.10.7, and the NetCDF library is upgraded to version 4.7.4.

Audio, Video, and Image I/O Functions: Run functions in a thread-


based environment
You can now run the following functions in the background using MATLAB backgroundPool:

• audioread
• audiowrite
• imwrite
• VideoReader
• VideoWriter

For more information, see Run MATLAB Functions in Thread-Based Environment.

Image File Format Libraries: LibTIFF library upgraded to version 4.2.0


The LibTIFF library is upgraded to version 4.2.0.

New Serial Explorer and TCP/IP Explorer apps


Two new apps offer functionality for communicating with your device, instrument, or server:

• The Serial Explorer app provides a user interface to connect to and communicate with a serial
port device on your machine.
• The TCP/IP Explorer app provides a user interface to create a TCP/IP client that communicates
with a TCP/IP server.

Launch these apps from the Apps tab, under the Test and Measurement section. You can also call
the serialExplorer and tcpipExplorer commands in the Command Window.

You can use the apps to perform the following operations on your serial port device or TCP/IP client.

• Configure connection and communication properties.


• Write binary or string data.

5-18
Data Import and Export

• Read binary or string data.


• Plot data in a separate figure window.
• Analyze data by viewing it in the Signal Analyzer app.
• Export data to the MATLAB workspace.
• Generate a MATLAB script for app interactions that uses the serialport or tcpclient
interface.

For more information about these apps, see Serial Explorer and TCP/IP Explorer.

Functionality being removed or changed


Video and Image I/O Functions: Pixel value differences might exist between JPEG 2000
images in R2021b and previous versions of MATLAB
Behavior change

In R2021b, when you use the imread, imwrite, VideoReader, or VideoWriter functions to read
or write JPEG 2000 image files, the image you import or export in R2021b might have pixel value
differences with the same image in previous versions of MATLAB.

HDF5 Interface: Linux users need to rebuild filter plugins using MATLAB HDF5 1.10.7
shared library
Behavior change

Starting in R2021b, in certain cases, Linux users using a filter plugin with callbacks to core HDF5
library functions need to rebuild the plugin using the shipping MATLAB HDF5 1.10.7 shared library, /
matlab/bin/glnxa64/libhdf5.so.103.3.0. If you do not rebuild the plugin using this version of
the shared library, you might experience issues ranging from undefined behavior to crashes. For more
information, see Build HDF5 Filter Plugins on Linux Using MATLAB HDF5 Shared Library or GNU
Export Map.

ftp Function: FTPClientConfig class, properties, and methods are no longer supported

The ftp function no longer supports the Apache® FTPClientConfig class or any associated objects,
properties, or methods. To customize how to parse the LIST command output of the FTP server use
the ftp function’s DirParserFcn name-value argument.

MATLAB Variable Editor: timeseries will no longer be supported in a future release


Still runs

Viewing timeseries objects using the MATLAB Variable Editor will no longer be supported in a
future release. To view time-indexed data in the Variable Editor, use timetable instead.

5-19
R2021b

Mathematics

ode78 and ode89 Functions: High-order Runge-Kutta solvers for


ordinary differential equations
The MATLAB ODE suite has been expanded with two new solvers:

• ode78 uses 7th- and 8th-order Runge-Kutta formulas


• ode89 uses 8th- and 9th-order Runge-Kutta formulas

The new solvers expand on the existing Runge-Kutta solvers ode23 and ode45. In particular, ode78
and ode89 can be more efficient than ode45 on nonstiff problems that are smooth, and ode89 can be
more efficient than ode78 on very smooth problems, when you integrate over long time intervals or
when tolerances are tight.

pagesvd Function: Perform singular value decomposition on pages of


N-D arrays
Use the pagesvd function to perform batched singular value decompositions on the pages of N-D
arrays. In this context, the N-D array is treated as a container for several 2-D matrices.

svd Function: Option to control output format of singular values


svd has a new option outputFormat to control whether the singular values are returned as a vector
or diagonal matrix.

mpower Function: Improved algorithm for defective matrices


The mpower function has an improved algorithm to handle defective matrices raised to a real power.
In previous releases, mpower uses an algorithm based on eigenvalue decomposition for these inputs
that can return incorrect results for defective matrices. The new algorithm for defective matrices is
instead based on the Schur decomposition.

Functionality being removed or changed


svd, eig, cond, and pinv functions return NaN for nonfinite inputs
Behavior change

In R2021b, the svd, eig, cond, and pinv functions return NaN values when the input contains
nonfinite values (Inf or NaN).

In previous releases, these functions throw an error when the input contains nonfinite values.

5-20
Graphics

Graphics

Plotting Table Data: Create scatter plots, bubble charts, and swarm
charts by passing tables directly to plotting functions
Create plots by passing a table directly to any of these functions: scatter, scatter3,
bubblechart, bubblechart3, swarmchart, swarmchart3, polarscatter, and
polarbubblechart. When you specify your data as a table, the axis labels and the legend (if
present) are automatically labeled using the table variable names.

The objects returned by these functions have new properties to support tables.

Property Description
SourceTable Table containing the data to plot
XVariable, YVariable, and ZVariable Table variables containing the x, y, and z values
for Cartesian plots
ThetaVariable and RVariable Table variables containing the angle and radius
values for polar plots
SizeVariable Table variable containing the marker size data
ColorVariable Table variable containing the marker color data
AlphaVariable Table variable containing the marker
transparency data

For example, create a table with the variables "Trials" and "Response". Pass the table to the
scatter function as the first argument, and indicate the variables you want to plot by name.

Trials = randi(10,50,1);
Response = rand(50,1);
t = table(Trials,Response);
scatter(t,"Trials","Response")

5-21
R2021b

Axes Ticks and Colors: Control the appearance of axis tick marks and
tick label colors
Now, you can remove tick marks and customize tick label colors independently of other elements in
the axes.

• Removing Tick Marks — Remove all the tick marks from an axes, polar axes, or geographic axes
object by setting the TickDir property to 'none'. To remove the tick marks from a specific axis,
for example the x-axis, set the TickDirection property of the ruler to 'none'.
• Customizing Tick Label Colors — Customize the color of the tick labels on an axis by setting
the TickLabelColor property of the corresponding ruler object. You can customize tick label
colors for any axes, polar axes, or geographic axes.

For example, create a bar chart, and then get the current axes. Remove the x-axis tick marks and
change the color of the x-axis tick labels to red.

bar([2017 2018 2019 2020],1:4)


ax = gca;
ax.XAxis.TickDirection = 'none';
ax.XAxis.TickLabelColor = 'r';

5-22
Graphics

Create Plot Live Task: Add additional visualizations to generated plots


Easily add additional visualizations to plots generated using the Create Plot Live Task. To add a new
plot, click the Add tab at the bottom of the Live Task Panel and select the visualization and data. This
Live Task combines the plot using the hold function.

5-23
R2021b

Create Plot Live Task: Control chart input syntax using configuration
drop-down
The Create Plot Live Task now supports multiple configurations of charting functions with multiple
input syntaxes, including surf and mesh. Use the Configurations drop-down menu to select the
desired configuration.

exportgraphics Function: Capture and append graphics to existing


PDFs
Capture and append graphics to an existing PDF file by calling the exportgraphics function and
setting the 'Append' name-value argument to true. For example, create a plot and export it as a
PDF called 'mycharts.pdf'. Then, create a bar chart and append it to the end of
'mycharts.pdf'. The resulting PDF file has two pages. The plots appear in the PDF in the order
that you export them.

plot([0 3 1 6 4 10])
exportgraphics(gca,'mycharts.pdf')
bar([10 20 30 40])
exportgraphics(gca,'mycharts.pdf','Append',true)

stackedplot Function: Support for semilog y-axes


You can create plots using the stackedplot function where individual y-axes can be plotted on a log
scale. To set a log scale for the y-axis of a plot, set the YScale property of the
StackedAxesProperties object associated with the plot. For more information, see
StackedAxesProperties Properties.

Text Objects: Use editInteractions in the Interactions property to click


or tap on text to edit
Click or tap to edit text when the Interactions property has the value editInteraction. The edit
interaction is default behavior for title, subtitle, xlabel, ylabel, and zlabel text objects for axes,
geographic axes, and polar axes.

dataTipTextRow Function: Customize data tip content using data


properties, such as UserData
You can now assign information to the DataTipTemplate property by passing it to the
dataTipTextRow function as a property name, such as UserData.

5-24
Graphics

p = patch;
p.UserData = p.XData;
p.DataTipTemplate.DataTipRows(3) = dataTipTextRow('XDataAsUserData','UserData');

MATLAB Online™ Accessibility: Use a screen reader to interact with


figures
In MATLAB Online™, you can use a screen reader and keyboard commands to pan, zoom, and rotate
when you work with plotted data. Using a screen reader is not supported in the Live Editor.

For more information, see Use a Screen Reader in MATLAB Online.

For more details on interacting with MATLAB figures, see Control Chart Interactivity.

Functionality being removed or changed


The print options -opengl and -painters are not recommended
Still runs

The following print options are no longer recommended. There are no plans to remove the values,
and they will continue to behave the same way as in previous releases. The following table lists the
recommended replacement options.

Not Recommended Replacement Option


The -opengl renderer option. For example: Use the -image option. For example:

print('-opengl','-dpdf','myfigure.pdf') print('-image','-dpdf','myfigure.pdf')
The -painters renderer option. For example: Use the -vector option. For example:

print('-painters','-dpdf','myfigure.pdf') print('-vector','-dpdf','myfigure.pdf')

plottools functions will be removed in a future release


Still runs

The plottools functions listed below will be removed in a future release. Use inspect to launch
the Property Inspector instead.

plottools functions

• plottools
• showplottool
• figurepalette
• plotbrowser
• propertyeditor
• propedit
• plotedit options 'showtoolsmenu' and 'hidetoolsmenu'

5-25
R2021b

App Building
uialert, uiconfirm, and uiprogressdlg Functions: Mark up text and
display equations in dialog boxes
When you create dialog boxes using the uialert, uiconfirm, and uiprogressdlg functions,
enable markup in the dialog box text using the Interpreter name-value argument. Specify the
interpreter as 'html', 'latex', 'tex', or 'none'.

addStyle Function: Add styles to nodes and levels in a tree UI


component
Create styles for specific tree nodes or tree node levels in a tree UI component using the uistyle
and addStyle functions. For example, you can make the tree nodes at the top level of the tree red
with italic font. To get information on applied styles, query the StyleConfigurations property of
the Tree object. To remove a style from a tree, use the removeStyle function.

uitable Function: Set and query table selections programmatically and


control table selection options
You can now configure selection options of table UI components.

• Set and query the table selection using the Selection property.
• Specify whether a user can select table cells, rows, or columns using the SelectionType
property.
• Specify whether a user can select single or multiple table elements using the Multiselect
property.
• Update your app whenever a user selects table data by specifying a SelectionChangedFcn
callback.

Selection options in table UI components are supported only in App Designer apps and in figures
created with the uifigure function.

For more information, see Table Properties.

uitextarea Function: Program apps to respond while a user is typing in


a text area component
You can now specify a ValueChangingFcn callback for a TextArea component. The component
executes the callback function repeatedly while a user types in the text area.

For more information, see TextArea Properties.

Run Code in the Background: Use parallel language to create more


responsive apps
You can now create apps that remain responsive while performing calculations in the background by
using backgroundPool.

5-26
App Building

Use the background pool with the following parallel language:

• parfeval and related functionality such as afterEach and afterAll


• parallel.pool.DataQueue and related functionality such as afterEach

For more information, see Use the Background to Make Your Apps More Responsive.

App Designer: Debug code in Code View


When debugging code in App Designer, you now can diagnose problems using debugging controls in
Code View. You can use the controls in the Run section of the Editor tab to run to the next
breakpoint, run the next line of code, or step into or out of a function.

You can also debug your app code using inline debugging controls. For example, to run to a specific
line of code and then pause, click the button to the left of the line. To step into a function, click the
button directly to the left of the function you want to step into. After stepping in, click the
button at the top of the file to run the rest of the called function, leave the called function, and then
pause.

When you step into a called function or file, App Designer displays a breadcrumb-style list of the
functions MATLAB executed before pausing at the current line (also called the function call stack).
The function call stack is shown at the top of the file and displays the functions in order, starting on
the left with the first called script or function, and ending on the right with the current script or
function in which MATLAB is paused.

App Designer: Efficiently manage your app code with tools and
shortcuts from Live Editor
Many of the tools and shortcuts for navigating and organizing code that are available in the Live
Editor can now be used in App Designer Code View. This table lists the functionality that is new to
App Designer.

Functionality Menu Item Keyboard Shortcut


Wrap comment Right-click the comment and Ctrl+J
select Wrap Comments, or in
the Editor tab, in the Code

section, click the button.


Navigate code using bookmarks In the Editor tab, in the Set or clear bookmark: Ctrl+F2
Navigate section, click
Bookmark. Then, select

5-27
R2021b

Functionality Menu Item Keyboard Shortcut


Bookmark to set or clear a Move to previous bookmark:
bookmark on the current line, or Shift+F2
select Previous or Next to
Move to next bookmark F2
navigate between the existing
bookmarks.

Print app code In the Editor tab, in the File Ctrl+P


section, click Print. You can
print the entire document or the
current selection.

Fold and expand code In the View tab, click the Expand current fold: Ctrl+Shift
buttons in the Code Folding +Period (.)
section. Collapse current fold: Ctrl
+Period (.)
Expand all folds: Ctrl+Shift
+Comma (,)
Collapse all folds: Ctrl+Comma
(,)

Toggle display preferences In the View tab, in the Display N/A


section, toggle line highlighting
and line numbers.

5-28
App Building

Functionality Menu Item Keyboard Shortcut


Duplicate line Right-click a line and select Ctrl+Shift+C
Duplicate Line(s).
Insert section break Right-click a line and select Ctrl+Alt+Enter, or type %%
Section Break.
Convert text to uppercase or Highlight the text, right-click it, Ctrl+Shift+A
lowercase and select Change Case.
Variable rename When you rename a variable, Shift+Enter
App Designer gives you the
option to automatically update
all other instances of the
variable in your code.

Compatibility Considerations
Code folding in App Designer persists even after you close and then reopen the file. In R2021a and
earlier releases, when opening a file, App Designer expands all the code.

App Designer: Interactively modify canvas zoom level and fit canvas
to view
In Design View, use the zoom controls in the lower right corner of the App Designer canvas,
indicated by the button, to modify the canvas zoom level.

To automatically zoom to fit the entire app in the view, press Space. Alternatively, click Fit to
View in the Zoom section of the View tab, or right-click on the canvas and select Zoom > Fit to
View.

App Designer: Convert between similar UI components


To convert one type of UI component to another with similar functionality, right-click the component
on the canvas or in the Component Browser and select Replace With. Then, select the component
to convert to. Replacing one component with another preserves relevant property values, such as font
properties and callbacks that exist for both components. You can convert component types within
each of these families:

• Numeric edit field, spinner, slider, and knob

5-29
R2021b

• Edit field and text area


• Label and hyperlink

App Designer: Add help text for your app


You can now provide help for apps that you create. Help text appears in the Command Window when
an app user calls the help function and specifies the name of the app.

To add help text, in the Editor tab in Code View, click App Help Text. Use the App Help Text
dialog box to specify the app summary and detailed explanation.

In addition, when an app user views the documentation for your app (for example, by calling the doc
function or by clicking the documentation link in the help text for the app), the documentation page
now displays additional information:

• The top of the page displays the app summary and detailed explanation.
• The Methods Summary section displays the public functions. For each function, it also displays
any comment that is inserted after the function definition statement.

App Designer: Remove auto-reflow behavior from an app with auto-


reflow
To convert an app with auto-reflow to an app without auto-reflow, in the Canvas tab in Design View,
click Convert. Select the App without Auto-Reflow option. Doing so creates a duplicate of your app
with the auto-reflow behavior removed.

For more information, see Apps with Auto-Reflow.

Deployed Web Apps: Deploy web apps directly to the MATLAB Web
App Server from within App Designer
Once you have MATLAB Compiler™ installed on the system running MATLAB, package your MATLAB
app into a web app from within App Designer by clicking Share in the Designer tab and selecting
Web App. In the packaging dialog, specify the server URL to directly deploy your web app to the
server once packaging is complete. Authentication must be enabled on the server for this to work. For
details, see Authentication (MATLAB Web App Server).

App Testing Framework: Perform press gestures on axes and UI axes


with different selection types
The app testing framework now supports mouse selection types in press gestures that are
performed on axes and UI axes. For example, create an axes with a plot and then test a double-click
gesture at the point (3, 2).
f = uifigure;
ax = axes(f);
plot(ax,1:10)
tc = matlab.uitest.TestCase.forInteractiveUse;
tc.press(ax,[3 2],'SelectionType','open')

5-30
App Building

App Testing Framework: Perform drag gestures on axes and figures


with different selection types
Starting in R2021b, the app testing framework supports drag gestures on UI figures. Additionally,
when you test a drag gesture on an axes, UI axes, or UI figure, you can specify the mouse selection
type. For example, create a figure and drag on it from the point (100, 200) to the point (200, 300)
using a right-click gesture.
f = uifigure;
tc = matlab.uitest.TestCase.forInteractiveUse;
tc.drag(f,[100 200],[200 300],'SelectionType','alt')

App Testing Framework: Use any units of measurement in gestures at


the center of components
Starting in R2021b, when you perform a gesture at the center of a component, the component or its
parent containers can use any units of measurement. In previous releases, the framework does not
support containers that use nonpixel units.

For example, create a figure and set its Units property to 'normalized'. Then, create a panel in
the figure and press at the center of the panel.
f = uifigure;
f.Units = 'normalized';
p = uipanel(f);
tc = matlab.uitest.TestCase.forInteractiveUse;
tc.press(p)

If you perform a gesture at the center of a component using a syntax that accepts location as an input
(for instance, press(testcase,comp,location)), then the figure or parent containers can use
only 'pixels' as their units of measurement.

Functionality being removed or changed


Ctrl+Click selects and deselects cells in a table UI component
Behavior change

In tables created using the uitable function, you can select and deselect noncontiguous table cells
by holding Ctrl and clicking a cell. In R2021a and earlier releases, Ctrl+Click gives focus to a cell
and Shift+Click selects the cell that has focus.

App Designer toolstrip organization has changed


Behavior change

The organization of the tools in the App Designer toolstrip in Design View and Code View has
changed.

In Design View, use the tools in the Canvas tab to lay out your app, and use the tools in the View
tab to manage your Design View preferences.

In Code View, use the tools in the Editor tab to program your app behavior and to run and debug
your app, and use the tools in the View tab to manage your Code View preferences.

matlab.fonts.editor.codefont.Size setting has been removed


Errors

5-31
R2021b

The matlab.fonts.editor.codefont.Size setting has been removed. Use the


matlab.fonts.codefont.Size setting instead. The matlab.fonts.codefont.Size setting
controls both the App Designer Code View font size and the desktop code font size.

To update your code, change instances of the setting matlab.fonts.editor.codefont.Size to


matlab.fonts.codefont.Size. For more information, see matlab.fonts Settings.

App Designer Smart Indent applies to individual lines


Behavior change

When you apply Smart Indent to code in App Designer, the indentation change applies only to the
current line. In R2021a and earlier releases, the Smart Indent option applied to the entire document.

To apply Smart Indent to the entire document, in Code View, first select all the code (for example, by

pressing Ctrl+A). Then, apply Smart Indent by clicking the button in the Editor tab, or pressing
Ctrl+I.

CellSelectionCallback property of table UI components is not recommended in uifigure-


based apps
Still runs

Starting in R2021b, using the CellSelectionCallback property to program a response to table


selection is not recommended for table UI components in App Designer apps and in figures created
with the uifigure function. Use the SelectionChangedFcn property instead.

To update your code, assign all callback functions assigned to the CellSelectionCallback
property to the SelectionChangedFcn property instead. If a callback function accesses the callback
event data, you might need to update the event property names. For example, to access the indices of
the elements the user selected, use the Selection property of the TableSelectionChangedData
object. For more information, see Table Properties.

5-32
Performance

Performance

table Data Type Indexing: Improved performance when assigning


elements by subscripting with curly braces
table subscripted assignment using curly braces is significantly faster in R2021b than in R2021a.

For example, when you assign into three table variables with 106 elements, performance in R2021b is
approximately 4.4x faster, as shown below.

function timingTest()
t = table(zeros(1e6,1), ones(1e6,1), nan(1e6,1));
indices = randi(1e6,1,10000);

tic;
% Assign row vector of random values to randomly chosen row
for i = indices
t{i,:} = rand(1,3);
end
toc
end

The approximate execution times are:

R2021a: 7.4 s

R2021b: 1.7 s

The code was timed on a Windows 10 system with a 3.6 GHz Intel Xeon W-2133 CPU by calling the
timingTest function in R2021a and R2021b.

qrinsert and qrdelete Functions: Improved performance modifying QR


factorizations
The qrinsert and qrdelete functions show improved performance inserting and deleting rows and
columns in a QR factorization. The speedup is most noticeable for square matrices of order 1000 or
less and is similar in magnitude for both rows and columns.

For example, this code uses a loop to insert and delete columns from the QR factorization of a random
200-by-200 matrix. qrinsert and qrdelete are about 12x faster than in the previous release.

function timingQRMod
X = rand(200);
[Q,R] = qr(X);
y = rand(200,1);
tic
for k = 1:1000
[Qn,Rn] = qrinsert(Q,R,100,y);
end
toc
tic
for k = 1:1000
[Qn,Rn] = qrdelete(Q,R,100);
end

5-33
R2021b

toc
end

The approximate execution times are:

R2021a: 1.7 s (insertion) and 1.2 s (deletion)

R2021b: 0.15 s (insertion) and 0.10 s (deletion)

The code was timed on a Windows 10, Intel Xeon W-2133 CPU @ 3.60 GHz test system by calling the
timingQRMod function.

Titles and Labels in Plots: Improved performance when creating and


querying titles or labels in a loop
Creating and querying the following types of titles and labels in a loop has improved performance.

• Plot titles, such as those created with the title or subtitle functions
• Axis labels, such as those created with the xlabel, ylabel, or zlabel functions

For example, this code creates 100 axes with titles in a tiled chart layout. It runs 11.9x faster than in
the previous release:

function timingTitle
tiledlayout(10,10);
for n = 1:100
nexttile
title(n)
end
end

The approximate execution times are:

R2021a: 9.5 s

R2021b: 0.8 s

The code was timed on a Windows 10, Intel Xeon CPU E5-1650 v4 @ 3.60 GHz test system by calling
the timeit function:

timeit(@timingTitle)

The performance gains increase with the number of axes, titles, and axis labels you are working with.
For example, this table shows the improvements for looping over 10, 20, 50, and 100 axes with titles.

Number of Axes with Titles Performance Gain


10 2.5x
20 4.2x
50 7.0x
100 11.9x

5-34
Performance

Plot Interactions: Improved performance for rendering data tips and


rotating scatter plots of large data sets
In figures created with the uifigure function and in MATLAB Online, interactions with scatter plots
of large data sets have the following performance improvements:

• Data tip markers track the mouse motion more closely.


• 3-D scatter plots are more responsive to rotation gestures.

This improvement can be seen when the axes are created with either the axes or uiaxes function.

For example, on a Windows 10, Intel Xeon CPU E5-1650 v4 @ 3.60 GHz system, when you hover the
cursor over the following sphere, the cursor changes to a crosshair more quickly, and the data tip
markers track the cursor more closely. When you click and drag the cursor within the axes, the
sphere rotates more quickly and tracks the cursor more closely.
f = uifigure;
ax = axes(f);
[X,Y,Z] = sphere(900);
scatter3(ax,X(:),Y(:),Z(:),[],Z(:),".")

Plots in Apps: Improved performance for creating plots


The performance is improved for creating plots in apps or in figures created with the uifigure
function. For example, create a figure and an axes object. Then plot 10,000 points. This code runs 14x
faster in R2021b.
function timingPlot
% Create figure and axes
f = uifigure;
ax = axes(f);
drawnow;

% Create data vector


y = rand(1,10000);

% Plot the data


tic;

5-35
R2021b

plot(ax,y);
toc;
end

The approximate execution times are:

R2021a: 0.14 s

R2021b: 0.01 s

The code was timed on a Windows 10, Intel Xeon W-2133 CPU @ 3.60 GHz test system by calling the
timingPlot function.

App Designer: Improved performance when opening Start Page and


loading apps
When you use App Designer, these operations have improved performance:

• Opening the App Designer Start Page


• Opening an existing app

For example, opening App Designer by entering appdesigner in the Command Window loads the
Start Page approximately 1.8x faster in R2021b than in R2021a the first time it is opened, and 2.1x
faster in subsequent times. The approximate startup times are:

Release First Startup Subsequent Startups


R2021a 6.6 s 3.6 s
R2021b 3.6 s 1.7 s

Also, loading an app in App Designer shows improved performance. For example, after creating and
saving a new blank app, opening the app in App Designer is about 1.3x faster in R2021b than in
R2021a. The approximate loading times are:

R2021a: 1.98 s

R2021b: 1.56 s

The performance improvement is larger if you have additional toolboxes installed.

These operations were timed on a Windows 10, Intel Core i7-5600 CPU @ 2.60 GHz test system.

App Designer: Improved performance when saving apps


Saving apps in App Designer after you edit an app function or property is faster in R2021b than in
R2021a. The more lines of code in the app file, the greater the performance improvement becomes.

For example, on a Windows 10, Intel Xeon W-2133 CPU @ 3.60 GHz test system, in an app containing

10,000 lines of code, if you click Property to create a new property and then click Save to
save the app, you can run the updated app sooner in R2021b than in R2021a.

The approximate save times are:

5-36
Performance

R2021a: 20 s

R2021b: 1.5 s

Comparison Tool: Improved performance when loading and saving


MLAPP files
When you use the Comparison Tool to compare and merge changes between app code in MLAPP files,
these operations have improved performance:

• Loading the files into the Comparison Tool


• Saving the files after merging changes

For example, if you load two apps with 5000 lines of code into the Comparison Tool by clicking

Compare in the App Designer toolstrip, you can compare and merge the files sooner in R2021b
than in R2021a.

The approximate loading times are:

R2021a: 13 s

R2021b: 8 s

Also, if you use the Comparison Tool to merge changes between two apps with 5000 lines of code (for

example, by clicking Merge Mode , merging the changes, and then clicking Save Result ), you
can compare the saved files sooner in R2021b than in R2021a.

The approximate save times are:

R2021a: 24 s

R2021b: 8 s

Both of these operations were timed on a Windows 10, Intel Xeon W-2133 CPU @ 3.60 GHz test
system.

uigridlayout Function: Improved performance when adding


components spanning multiple columns with 'fit' width
The performance of parenting components to a grid layout manager created using the
uigridlayout function has improved when the components span multiple columns with a
ColumnWidth value of 'fit'. The performance improvement gets better as the number of
components spanning multiple columns and the number of columns spanned increases.

For example, this code creates a grid layout manager with 10 columns with a ColumnWidth value of
'fit', and then creates 50 labels that span all 10 columns. Performance in R2021b is about 4.7x
faster than in R2021a.
function timingGridLayout
f = uifigure;
numrows = 50;
numcols = 10;

5-37
R2021b

g = uigridlayout(f);
g.Scrollable = 'on';
g.RowHeight = repmat({'fit'},1,numrows);
g.ColumnWidth = repmat({'fit'},1,numcols);
drawnow

tic
for row = 1:numrows
txt = ['This is a label in row ' num2str(row) ' that spans ' ...
num2str(numcols) ' columns in the grid.'];
lbl = uilabel(g,'Text',txt);
lbl.Layout.Column = [1 numcols];
end
drawnow
toc
end

The approximate execution times are:

R2021a: 5.2 s

R2021b: 1.1 s

The code was timed on a Windows 10, Intel Xeon CPU E5-1650 v4 @ 3.60 GHz test system by calling
the function timingGridLayout.

uigridlayout Function: Improved resizing performance when wrapping


text in resizable columns
The performance when you resize apps containing a grid layout manager created using the
uigridlayout function has improved when both of these conditions hold:

• The grid layout manager contains a component with a WordWrap value of 'on'.
• The row and column containing the component with word wrap have a RowHeight of 'fit' and a
ColumnWidth that is resizable, such as '1x'.

For example, on a Windows 10, Intel Xeon CPU E5-1650 v4 @ 3.60 GHz test system, if you create 100
labels with wrapping text in a grid layout manager with fit height rows and resizable columns, and
then resize the figure window by dragging the corner of the figure, the label text adjusts to fit the size
of the figure almost immediately. In R2021a, there is a delay of about 2 seconds before the text
adjusts.

f = uifigure;
g = uigridlayout(f);
g.ColumnWidth = {'1x'};
numrows = 100;
g.RowHeight = repmat({'fit'},numrows,1);

for row = 1:numrows


c = uilabel(g);
c.Text = ['Lorem ipsum dolor sit amet, consectetur adipiscing elit,' ...
' sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.'];
c.WordWrap = 'on';
end

5-38
Performance

Live Editor: Improved performance when saving live scripts or


functions
Saving live scripts and live functions in the Live Editor is faster in R2021b than in R2021a. The
improvement is most noticeable when you save live functions with more than 1000 lines of code and
live scripts with fewer than 100 lines of code.

For example, on a Windows 10, Intel Xeon E5-1650 CPU @ 3.60 GHz test system, saving an example
live function containing 4000 lines of code takes approximately 2.05 seconds in R2021b. In R2021a,
saving the same live function takes approximately 2.57 seconds.

Data Processing Dialog Boxes: Improved resizing performance


The Basic Fitting UI, Data Statistics UI, Colormap Editor, and Linked Plot Data Sources dialog now
use uigridlayout to manage positions of UI components. This change results in a smoother experience
when adjusting the size of these dialog boxes. For more information about the Data Statistics UI,
see Computing with Descriptive Statistics.

For example, on a Windows 10, Intel Xeon E5-1650 CPU @ 3.60 GHz test system, when you increase
the size of the Colormap Editor, the size changes smoothly.

Figure Interactions: Improved performance when using built-in axes


interactions
Performance of figure interactions has been improved by coalescing built-in axes interactions so that
there are significantly fewer interactions to process. These changes make interacting with a plot
smoother and reduce the delay between an input and a response.

For example, on a Windows 10, Intel Xeon E5-1650 CPU @ 3.60 GHz test system, while
panInteraction mode is active, when you click and drag the cursor within the axes the figure pans
more quickly and tracks the cursor more closely.

5-39
R2021b

UI Figures: Improved performance when displaying axes toolbar


The performance of the axes toolbar in UI figures has been improved to reduce the delay before the
toolbar appears.

For example, on a Windows 10, Intel Xeon E5-1650 CPU @ 3.60 GHz test system, when you pause the
cursor on the axes, the axes toolbar appears more quickly.

UI Figures: Improved performance when interacting with linked axes


Interacting with linked axes has improved performance when using figures created with the
uifigure function or figures created in MATLAB Online™.

5-40
Software Development Tools

Software Development Tools


Projects: Collaborate using projects in MATLAB Online
Starting in R2021b, MATLAB Online provides support for basic projects workflows:

• Create an empty project and add files and folders.


• Clone a project from Git.
• Explore your project and run a dependency analysis.
• Create a project and manage your project files programmatically.

Source Control: Work with files under Git in MATLAB Online


Starting in R2021b, MATLAB Online provides support for basic Git workflows:

• Cloning a remote Git repository


• Committing files to Git
• Pulling, pushing, and fetching files with Git

Unit Testing Framework: Use the TestCase class template to create


tests more quickly and accurately
You can now create a TestCase class, including basic test functionality, in MATLAB and MATLAB
Online. To create a new test class, select New > Test Class on the Home, Editor, or Live Editor
tabs.

Use the TestCase class template to create tests more conveniently. The template includes a
TestClassSetup methods block, a TestMethodSetup methods block, and a Test methods block
that defines a simple Test method. To customize your test class, add code to the file or remove
unused code that is included by default. For more information about class-based tests, see Author
Class-Based Unit Tests in MATLAB.

Unit Testing Framework: Run live-function-based tests interactively in


MATLAB Online
Starting in R2021b, you can run live-function-based tests interactively in MATLAB Online. When you
open an MLX file defining a function-based test in MATLAB Online, the toolstrip lets you run all tests
in the file or just the current test.

To run tests and customize your test run interactively, use the Run Tests section in the Live Editor
tab of the toolstrip. For more information, see Run Tests in Editor.

App Testing Framework: Perform press gestures on axes and UI axes


with different selection types
The app testing framework now supports mouse selection types in press gestures that are
performed on axes and UI axes. For example, create an axes with a plot and then test a double-click
gesture at the point (3, 2).

5-41
R2021b

f = uifigure;
ax = axes(f);
plot(ax,1:10)
tc = matlab.uitest.TestCase.forInteractiveUse;
tc.press(ax,[3 2],'SelectionType','open')

App Testing Framework: Perform drag gestures on axes and figures


with different selection types
Starting in R2021b, the app testing framework supports drag gestures on UI figures. Additionally,
when you test a drag gesture on an axes, UI axes, or UI figure, you can specify the mouse selection
type. For example, create a figure and drag on it from the point (100, 200) to the point (200, 300)
using a right-click gesture.
f = uifigure;
tc = matlab.uitest.TestCase.forInteractiveUse;
tc.drag(f,[100 200],[200 300],'SelectionType','alt')

App Testing Framework: Use any units of measurement in gestures at


the center of components
Starting in R2021b, when you perform a gesture at the center of a component, the component or its
parent containers can use any units of measurement. In previous releases, the framework does not
support containers that use nonpixel units.

For example, create a figure and set its Units property to 'normalized'. Then, create a panel in
the figure and press at the center of the panel.
f = uifigure;
f.Units = 'normalized';
p = uipanel(f);
tc = matlab.uitest.TestCase.forInteractiveUse;
tc.press(p)

If you perform a gesture at the center of a component using a syntax that accepts location as an input
(for instance, press(testcase,comp,location)), then the figure or parent containers can use
only 'pixels' as their units of measurement.

Functionality being removed or changed


Specifying diagnostic after name-value arguments in qualifications is not recommended
Still runs

Starting in R2021b, when you test for equality using the verifyEqual, assumeEqual,
assertEqual, or fatalAssertEqual methods, specifying name-value arguments before the
diagnostic input argument is not recommended. Place name-value arguments after all of the
positional arguments instead. Although not recommended, you still can specify diagnostic after the
name-value arguments when these arguments use the name,value syntax.

The reason for this change is that, starting in R2021a, MATLAB supports a new syntax for passing
name-value arguments. In the new syntax, the name and value arguments are connected by an equals
sign (name=value), and the name is not enclosed in quotes. To use the new syntax with qualification
methods, specify positional arguments, including diagnostic, before the name=value arguments. If
you specify diagnostic after name=value arguments, MATLAB produces an error.

This table shows an example of how you can update your code.

5-42
Software Development Tools

R2021a and Earlier Starting in R2021b


testCase = matlab.unittest.TestCase.forInteractiveUse;
testCase = matlab.unittest.TestCase.forInteractiveUse
verifyEqual(testCase,1.5,2, ... verifyEqual(testCase,1.5,2, ...
"RelTol",0.1,"Difference must be within relative
"Difference
tolerance.")
must be within relative tolerance.",R
assumeEqual(testCase,1,2, ... assumeEqual(testCase,1,2, ...
"AbsTol",0.5,"Difference must be within absolute
"Difference
tolerance.")
must be within absolute tolerance.",A

For more information, see verifyEqual.

matlab.unittest.TestSuite.fromProject ignores the files that do not define test procedures


when creating a test suite
Behavior change

Starting in R2021b, if your project includes files with the Test classification,
matlab.unittest.TestSuite.fromProject ignores the files that do not define test procedures
when you create a test suite. For example, if an abstract TestCase class definition file is labeled with
the Test classification, fromProject ignores it. In previous releases, MATLAB produces an error if
fromProject is called on a project that uses the Test classification for any files other than concrete
test files. With this change, fromProject becomes consistent with the
matlab.unittest.TestSuite.fromFolder method: both methods create a test suite from all the
concrete test files and ignore any other files in the folder.

This behavior change also applies to the testsuite, runtests, and runperf functions when they
operate on code organized into files and folders within a project.

Test suites created from projects cannot run without the Java Virtual Machine (JVM)
software
Behavior change

Starting in R2021b, if you start MATLAB without the Java Virtual Machine (JVM™) software and
create a suite from the test files in a project using testsuite, the function uses the
matlab.unittest.TestSuite.fromProject method to create the suite. If you then try to run the
test suite without the JVM software, MATLAB produces an error because the project cannot be
opened without the JVM software. In previous releases, when MATLAB runs without the JVM
software, testsuite uses matlab.unittest.TestSuite.fromFolder to create a suite from the
test files in the project, and the testing framework runs the resulting test suite.

This behavior change also applies to the runtests and runperf functions when they operate on
code organized into files and folders within a project.

5-43
R2021b

External Language Interfaces


C++ interface: Support for C++ language features
The C++ interface supports these additional C++ language features.

Support for void** parameters

MATLAB returns a void* argument for void** parameters. For more information, see void** Input
Argument Types. For information about memory management of void** parameters, see Pass
Ownership of Memory to MATLAB.

char [] parameters behave like char * parameters

MATLAB supports char[] parameters as either integer or character (string), the same as char*
parameters. Likewise, the Unicode types wchar_t[], char16_t[], and char32_t[] behave like
wchar_t*, char16_t*, and char32_t*. For more information, see C++ char* and char[] Types.

Support for static data members

Public static and public const static data members are treated as read-only properties in MATLAB.
You cannot modify the value of a C++ static data member in MATLAB. For more information, see
Static Data Members.

You can use a public static data member (property) as the data type of an input argument or return
type in a class constructor, method, or function. You also can use a static property or method to define
the shape of an argument. For information about using static properties to define the shape, see Use
Property or Method as SHAPE.

C++ interface: Publisher options


The C++ interface supports these build configuration features.

Overwrite existing library definition files

Publishers can automatically overwrite existing library definition MLX files when calling
clibgen.generateLibraryDefinition. Set the OverwriteExistingDefinitionFiles name-value
argument to true. This option is useful when you create and modify the definition file for a library
libname.

When you use this option, MATLAB deletes definelibname.mlx and definelibname.m, including
any edits you made to the files.

Options for defining arguments

• By default, when a MATLAB input has fewer dimensions than the corresponding C++ argument,
then MATLAB inserts singleton dimensions at the beginning of the Shape argument. For more
information, see Dimension Matching. To insert singleton dimensions at the end, set the
'AddTrailingSingletons' name-value argument to true in the defineArgument functions -
defineArgument (ConstructorDefinition), defineArgument (FunctionDefinition),
and defineArgument (MethodDefinition).
• If a C++ function has a character array parameter used to return a C++ string, you can define
the argument so that the function returns a null-terminated string. Use the

5-44
External Language Interfaces

'NumElementsInBuffer' name-value argument in the defineArgument


(FunctionDefinition) or defineArgument (MethodDefinition) functions. For an
example, see the getMessage function in the Define String Argument table.
• You can transfer ownership of the memory of function or method parameters of double pointer
type with scalar output to MATLAB using the DeleteFcn name-value argument. For more
information, see defineArgument (FunctionDefinition) and defineArgument
(MethodDefinition).
• MATLAB lets you control the lifetime management of objects created with a constructor by
specifying the ReleaseOnCall name-value argument in the library definition file. For more
information, see defineArgument (ConstructorDefinition) and Lifetime Management of C
++ Objects in MATLAB.
• You can use a method or a property to define the shape of an argument. For more information, see
Use Property or Method as SHAPE.
• You can transfer ownership to MATLAB of the memory of double pointer input arguments void**
and object**. Use the 'DeleteFcn' name-value argument for defineArgument, as described
in Pass Ownership of Memory to MATLAB.

Java interface: Specify JRE path for MATLAB


You can run MATLAB with your system version of the Java Runtime Environment (JRE). For
information about Java versions compatible with MATLAB, see MATLAB Interfaces to Other
Languages.

To set the JRE path in MATLAB, call jenv. You must restart MATLAB to use the updated path. This
command sets the path for all future MATLAB sessions but does not change the path for other
applications on your computer.

Alternatively, you can set the path from the operating system prompt. Call matlab_jenv, then start
MATLAB.

Java: Call into MATLAB from a Java program called by MATLAB


Java developers can use the com.mathworks.engine.MatlabEngine API getCurrentMatlab
method to call back into MATLAB from Java. Incorporating this method in your application allows
MATLAB users to call functionality from your Java program.

For information about developing these Java programs, see Call Back into MATLAB from Java.

Python interface: Run Python commands and scripts from MATLAB


The pyrun and pyrunfile functions let you call Python commands and scripts from MATLAB. For
more information, see Directly Call Python Functionality from MATLAB

Python: Support for complex multidimensional arrays


MATLAB supports passing complex multidimensional array data to Python and from Python to
MATLAB, for both in-process and out-of-process execution modes. For example, create a file test.py
containing this code:

5-45
R2021b

def returnData(data):
return data

To pass a complex MATLAB array to returnData, type:

mc = complex(magic(3));
c = py.test.returnData(mc)

c =
Python memoryview:

8.0000 + 0.0000i 1.0000 + 0.0000i 6.0000 + 0.0000i


3.0000 + 0.0000i 5.0000 + 0.0000i 7.0000 + 0.0000i
4.0000 + 0.0000i 9.0000 + 0.0000i 2.0000 + 0.0000i

Use details function to view the properties of the Python object.

Use double function to convert to a MATLAB array.

To convert the return value to a MATLAB array, type:

C = double(c)

C = 3×3 complex
8.0000 + 0.0000i 1.0000 + 0.0000i 6.0000 + 0.0000i
3.0000 + 0.0000i 5.0000 + 0.0000i 7.0000 + 0.0000i
4.0000 + 0.0000i 9.0000 + 0.0000i 2.0000 + 0.0000i

For information about MATLAB to Python data type mapping, see Pass Matrices and Multidimensional
Arrays to Python.

Python: Version 3.9 support


MATLAB now supports CPython 3.9, in addition to existing support for 2.7, 3.7, and 3.8. For more
information, see Versions of Python Compatible with MATLAB Products by Release

WSDL Web Services Documents: Apache CXF version 3.4.2 support


MATLAB supports Apache CXF version 3.4.2 for use with WSDL Web services. For more information,
see Set Up WSDL Tools.

Compatibility Considerations
Download the latest version 3.4.2 release of the Apache CXF tool from https://cxf.apache.org/
download.

Perl 5.32.1: MATLAB support on Windows


As of R2021b, MATLAB on Windows ships with an updated version of Perl, version 5.32.1. See https://
www.perl.org for a standard distribution of Perl, Perl source code, and information about using Perl.

5-46
External Language Interfaces

Compatibility Considerations
If you use the perl command on Windows platforms, see https://www.perl.org for information about
using this version of the Perl programming language.

Functionality being removed or changed


name=value syntax errors for calls to Python functions using py. prefix
Behavior change

Starting in R2021b, MATLAB errors when you use name=value syntax for passing keyword
arguments to Python functions using the py. prefix. In R2021a, MATLAB might silently give the
wrong answer. Use pyargs to pass keyword arguments.

For example, the Python print function has a keyword argument sep. This Python statement sets
the sep argument to a comma followed by a space:

print('comma','separated','values',sep=', ')

When you call this statement in MATLAB, MATLAB interprets sep=', ' as a name=value argument:

py.print('comma','separated','values',sep=', ')

R2021a Behavior R2021b Behavior How to Update Your Code


py.print(... py.print(... py.print(...
'comma','separated','values',...
'comma','separated','values',...
'comma','separated','values',...
sep=', ') sep=', ') pyargs(sep=', '))

Silent wrong answer: Error: comma, separated, values

comma separated values sep , Error using py.print


Using name=value format is not supported.
Use pyargs to pass keyword arguments

createSoapMessage, callSoapService, and parseSoapResponse have been removed


Errors

Consider using matlab.wsdl.createWSDLClient instead of the createSoapMessage,


callSoapService, and parseSoapResponse functions to communicate with Web services using
Simple Object Access Protocol (SOAP). There is no direct function replacement for the SOAP
functions, but when you create a WSDL interface, you have access to the Web service functionality.

createClassFromWsdl has been removed


Errors

The matlab.wsdl.createWSDLClient function replaces the createClassFromWsdl function to


communicate with Web services from MATLAB using Web Services Description Language (WSDL).
matlab.wsdl.createWSDLClient enables you to specify additional information needed to access
the WSDL document. For more information, see weboptions.

To get started using matlab.wsdl.createWSDLClient, follow these steps.

5-47
R2021b

1 Download supported versions of the Java JDK and Apache CXF programs. For more information,
see Set Up WSDL Tools.
2 Set the paths to these programs, where jdk is the path to the JDK installation and cxf is the
path to the CXF program.

matlab.wsdl.setWSDLToolPath('JDK',jdk,'CXF',cxf)

To update your code, replace calls to createClassFromWsdl with calls to


matlab.wsdl.createWSDLClient. For example, for a Web service with this URL:
url = 'https://examplesite.com/samplewebservice';

replace this call to createClassFromWsdl:


createClassFromWsdl(strcat(url,'?WSDL'))

with:

matlab.wsdl.createWSDLClient(url)

Note matlab.wsdl.createWSDLClient does not support RPC-encoded WSDL documents.

5-48
Hardware Support

Hardware Support

Connect and Control Arduino board using the Arduino Explorer App
The MATLAB Support Package for Arduino Hardware now has an Arduino Explorer app.

Using this app, you can:

• Set up the Arduino board


• Connect to an Arduino board over USB, Bluetooth®, and WiFi
• Configure, read from, and write to Arduino pins
• Visualize data from Arduino pins
• Record and save data from Arduino pins to the MATLAB workspace
• Analyze the recorded data
• Generate equivalent MATLAB code

Read data from APDS9960 sensor connected to the Arduino hardware


The MATLAB Support Package for Arduino Hardware enables you to read gesture, proximity, clear
light and color (RGB) data from APDS9960 sensor connected to Arduino hardware.

Support for CAN shields on Raspberry Pi Hardware


Use the MATLAB Support Package for Raspberry Pi Hardware to read and write CAN messages from
the CAN network on the Raspberry Pi hardware.

5-49
6

R2021a

Version: 9.10

New Features

Bug Fixes

Compatibility Considerations
R2021a

Environment
Live Editor Controls: Create dynamic controls in live scripts by linking
variables to drop-down items and slider values
When adding a drop-down list to a live script, you can populate the items in it using values stored in a
variable. When adding a slider, you can specify the minimum, maximum, and step values using
variables.

For example, create a live script and define the variable lastnames that contains a list of last names.
lastnames = ["Houston","Vega","Obrien","Potter","Rivera","Hanson","Fowler","Tran","Briggs"];

Run the live script to create lastnames and add it to the workspace. Then, go to the Live Editor
tab, and in the Code section, select Control > Drop Down. In the Items section of the control
configuration menu, select lastnames as the Variable.

Close the configuration menu to return to the live script. The drop-down list now contains the last
names defined in lastnames.

If you add, remove, or edit the values in lastnames, the items in the drop-down list update
accordingly.

6-2
Environment

For more information, see Add Interactive Controls to a Live Script.

Live Editor Fonts: Change the name, style, size, and color of fonts
programmatically using settings
You can change the name, style, size, and color of titles, headings, text, and code in the Live Editor
using settings.

For example, this code changes the color and style of titles in the Live Editor:

s = settings;
s.matlab.fonts.editor.title.Style.PersonalValue = {'bold'};
s.matlab.fonts.editor.title.Color.PersonalValue = [0 0 255 1];

This code increases the size and changes the font of normal text in the Live Editor:

s = settings;
s.matlab.fonts.editor.normal.Size.PersonalValue = 20;
s.matlab.fonts.editor.normal.Name.PersonalValue = 'Calibri';

The Live Editor updates all open live scripts and live functions to show the selected fonts. When you
create new live scripts or functions, they use the new fonts as well.

For more information, see matlab.fonts.

Live Editor Display: Specify where to display output by default


You can change the default location for output in a new live script. Depending on this preference, new
live scripts that you create display their output inline or on the right. To change the default, go to the
Home tab, and in the Environment section, select Preferences. Select MATLAB > Editor /
Debugger > Display, and then select an option for the Live Editor default view:

• Output on right — Output displays to the right of the code. Each output displays next to the line
that creates it. This option is ideal when writing code.
• Output inline — Output displays inline with the code. Each output displays underneath the line
that creates it. This option is ideal for sharing.

6-3
R2021a

Live Editor Functions: Run live functions interactively using the Run
button in MATLAB Online

In MATLAB Online, you can now run live functions interactively using the Run button.

To run live functions that require input argument values or any other additional setup, configure the

Run button by clicking Run and adding one or more commands. For more information about

configuring the Run button, see Configure the Run Button for Functions.

Live Editor Bookmarks: Navigate quickly between lines


To navigate quickly between lines, set bookmarks in your live scripts or live functions. Bookmarks are
particularly useful in long files when you frequently need to move between sections.

To set a bookmark, put the cursor on the line that you want to set it on. Then, go to the Live Editor

tab and, in the Navigate section, click Bookmark. A bookmark icon appears to the left of the
line. To clear a bookmark, with the cursor on the line with the bookmark, click Bookmark and
select Set/Clear. You also can clear the bookmark by clicking the bookmark icon to the left of the
line.

To navigate to a bookmark, go to the Live Editor tab, and in the Navigate section, click Bookmark
. Then, select Previous or Next.

For more information about navigating within files, see Go To Location in File.

Live Editor Animation Playback Controls: Interactive interface to


control animations
Playback controls now appear within the figure window after an animation is done playing. These
playback controls provide the ability to replay the animation and explore individual frames without
having to re-run the entire live script. Animation playback controls are not supported for animations
generated by the movie function.

Live Editor Performance: Improved performance when saving large


live scripts or functions
When saving large live scripts or functions, you can continue using the Live Editor sooner in R2021a
than in R2020b. While you continue to use the Live Editor, MATLAB saves the file in the background.
When MATLAB finishes saving the file, the asterisk (*) next to the file name disappears, indicating
that the file is saved.

For example, on a Windows 10, Intel Xeon E5-1650 CPU @ 3.60 GHz test system, if you save a live
script containing 35,000 lines of code and then click the title bar of another document open in the
Live Editor, MATLAB immediately switches to the other open document. In R2020b, there is a
noticeable delay before MATLAB switches to the other open document.

6-4
Environment

Help Browser: View web documentation by default


Starting in R2021a, when you run MATLAB with an internet connection, the Help browser displays
the web documentation by default. When you run MATLAB on a system without an internet
connection, or if your internet connection becomes unavailable, the Help browser displays the
installed documentation instead.

To change the default documentation location, on the Home tab, in the Environment section, click
Preferences. Select MATLAB > Help and change the Documentation Location. For more
information, see Help Preferences.

Documentation: View MATLAB documentation in French, Italian, and


German
A subset of MATLAB documentation in French, Italian, and German is available on the web to
licensed MATLAB users. Only a subset of the full documentation is available. For more information,
see Translated Documentation.

MATLAB Drive: Get the location of your MATLAB Drive root folder
programmatically
You can get the location of your MATLAB Drive root folder programmatically, using the matlabdrive
command, from your desktop or in other MATLAB environments such as MATLAB Online. For
example, if you have MATLAB Drive Connector installed on your desktop system, MATLAB returns the
location of your MATLAB Drive:

md = matlabdrive

md =
'C:\Users\username\MATLAB Drive'

MATLAB Drive: Pause and resume syncing in MATLAB Drive Connector


You can temporarily stop the syncing of your MATLAB Drive files, for example, if you are on a
metered or slow internet, by pausing and then resuming syncing.

For more information, see “Start and Stop MATLAB Drive Connector”

MATLAB Drive: MATLAB Drive Connector now available in Chinese and


Korean
MATLAB Drive Connector now available in Chinese and Korean.

MATLAB Drive: Change the folder permissions for an invited member


of a shared folder in MATLAB Drive Online (May 2021)
After inviting someone to access a shared folder, you can change the folder permissions for that
person. For example, if you invite someone to share a folder as a read-only folder, you can change the
permissions for that person to allow them to edit the contents of the folder.

6-5
R2021a

For more information, see “Share Folders Using MATLAB Drive”.

MATLAB Drive: Share folder by invitation to others who already have


access to the folder through a view-only link (May 2021)
You can now invite others to access a shared folder even if they already have access to the folder
through a view-only link. Inviting someone to access a shared folder allows you to give them edit
permissions to the folder.

Functionality being removed or changed


PNG images in documentation are compressed
Behavior change

Starting in R2021a, all PNG images included in the documentation are compressed, reducing their
stored size on disk. The compressed images should be visually identical to the original images.

6-6
Language and Programming

Language and Programming

Name=Value Syntax: Use name=value syntax for passing name-value


arguments
MATLAB supports a new syntax for passing name-value arguments. In the new syntax, the name and
value arguments are connected by an equal sign, and the name is not enclosed in quotes.

Name=value syntax: plot(x,y,LineWidth=2)

Comma-separated syntax: plot(x,y,"LineWidth",2)

MATLAB continues to support the comma-separated name,value syntax. Existing functions and
methods support both syntaxes, and the process for writing functions and methods with name-value
arguments is unchanged.

Use the new syntax to help identify name-value arguments for functions and to distinguish names
from values in lists of name-value arguments. There are some limitations on where and how the
name=value syntax can be used:

• The recommended practice is to use only one syntax in any given function call. However, if you do
mix name=value and name,value syntaxes in a single call, all name=value arguments must
appear after the name,value arguments. For example,
plot(x,y,"Color","red",LineWidth=2) is a valid combination, but
plot(x,y,Color="red","LineWidth",2) errors.
• Similarly, name=value arguments must appear after all positional arguments. Calling
myFunction(name=value,posArgument) errors.
• The name=value syntax can only be used directly in function calls. They cannot be wrapped in a
cell array or additional parentheses. Calling myFunction(a,(name=value)) errors.

Retrieving Display Format: format function can get and set display
format
The format function can now output the current Command Window display format. Calling format
with an output variable returns a DisplayFormatOptions object that describes the current
numeric and line spacing formats:

fmt = format

fmt =
DisplayFormatOptions with properties:

NumericFormat: "shortE"
LineSpacing: "loose"

You can also use a DisplayFormatOptions object as an input to format to change the display
format.

6-7
R2021a

Capturing disp Output: Use the formattedDisplayText function to store


disp output as a string
formattedDisplayText captures the output of disp(obj) as a string. The function also enables
you to control the formatting of the captured string, including numeric format and line spacing. For
example, A is a vector containing three logical values. formattedDisplayText displays the vector
elements as the words “true” or “false”:

out = formattedDisplayText(A,"UseTrueFalseForLogical",true)

out =
' true false true
'

Virtual File Storage: mkdir and rmdir will now be able to create and
remove files from VFS directories
Starting in R2021a, rmdir and mkdir are able to create folders in remote locations.

Function Argument Validation: Debugger and profiler is now


supported
The MATLAB debugger will now be usable inside of the arguments blocks of functions. While
debugging an arguments block the workspace is read only. The MATLAB profiler will now record
lines inside of arguments blocks.

Class Diagram Viewer: Create graphical class diagrams to explore


class details and share designs
Use the Class Diagram Viewer tool to create graphical class diagrams, including details such as:

• Inheritance relationships, including abstract classes, mixins, and multiple inheritances


• Lists of properties, methods, and events
• Class member access levels

You can use the diagrams to explore complex class designs. You can also use the diagrams to share
proposed designs with team members, either as static images or editable diagrams.

Use the associated matlab.diagram.ClassViewer class for command line access to diagrams.

Enumeration Comparisons: Use isequal to compare enumeration


members with text data types
Enumeration classes now have a default implementation of the isequal method. You can use
isequal to compare enumeration members with character vectors, strings, and cell arrays of
character vectors or strings. For more information, see isequal Method.

6-8
Language and Programming

eval function: Context checking to resolve identifiers


MATLAB now resolves identifiers like variable names in an eval statement using additional context.
For instance, MATLAB recognizes when a call to eval uses a variable declared in a function.

Compatibility Considerations
With the additional context, MATLAB resolves ambiguities differently than in previous releases. Some
code now produces errors or warnings.

Code that warns starting in R2021a will error in a future release.

Example Previous Result R2021 Result Notes


function myfun(pi) ans = Errors MATLAB resolves pi as
eval('pi') a variable in the
end 3.1416 function workspace, so
myfun now errors when
>> myfun
pi is not defined.
function myfun 3.1416 Same output but warns MATLAB resolves pi as
disp(pi) on assignment. a variable in the
eval('pi = 1'); pi = function workspace.
end
1 In a future release,
>> myfun
myfun errors. This new
behavior is consistent
with processing the
following code:

function myfun
disp(pi)
pi = 1;
end
% assignLocal.m script:
local fx Same output but warns In a future release,
local = 1; on assignment. MATLAB will give
local = precedence as
% myfun.m file with local
1 function: described in “Function
function myfun
Precedence Order”. In
local()
assignLocal this example,
eval("local") precedence goes to the
end local function. This new
function local behavior is consistent
disp("local fx") with processing the
end following code:
% function call: function myfun
>> myfun local()
assignLocal
local()
end

6-9
R2021a

Functionality being removed or changed


format with no arguments is not recommended
Still runs

The format command, by itself, resets the output display format to the default, which is the short,
fixed-decimal format for floating-point notation and loose line spacing for all output lines.

format

For clearer code, explicitly specify the default style.

format default

Defining classes and packages: Using schema.m will not be supported in a future release
Still runs

Support for classes and packages defined using schema.m files will be removed in a future release.
Replace existing schema-based classes with classes defined using the classdef keyword.

compose does not accept an invalid hexadecimal value, octal value, or trailing backslash
Errors

Previously, when the formatSpec input to compose contained an invalid hexadecimal value, octal
value, or trailing backslash it would issue a warning and truncate the output at the point of the
invalid value. Starting in R2021a, MATLAB will issue an error instead. With this change, compose will
error for all invalid formatSpec inputs.

Using get and set to access or change display format is not recommended
Still runs

Using get and set to programmatically access or change the numeric display format and the display
line spacing is not recommended. Use settings instead. For example:

s = settings;
myformat = s.matlab.commandwindow.NumericFormat.ActiveValue

myformat =
'short'

s.matlab.commandwindow.DisplayLineSpacing.TemporaryValue = 'compact';
myspacing = s.matlab.commandwindow.DisplayLineSpacing.ActiveValue

myspacing =
'compact'

For more information, see matlab.commandwindow Settings.

Using feature('EightyColumns') to access and change Command Window display width is


not recommended
Still runs

6-10
Language and Programming

Using the command feature('EightyColumns') or feature('EightyColumns',value) to


programmatically determine or change whether the Command Window display width limit is enabled
is not recommended. Use settings instead. For example:
s = settings;
s.matlab.commandwindow.UseEightyColumnDisplayWidth.TemporaryValue = 1;
limitwidth = s.matlab.commandwindow.UseEightyColumnDisplayWidth.ActiveValue

limitwidth =
logical
0

For more information, see matlab.commandwindow Settings.

6-11
R2021a

Data Analysis

Data Preprocessing Live Editor Tasks: Operate on multiple table


variables and specify output format for table input
When you are working with data in a table or timetable, these Live Editor tasks now allow you to
operate on multiple table variables at the same time:

• Clean Missing Data


• Clean Outlier Data
• Smooth Data
• Remove Trends
• Find Local Extrema
• Find Change Points

You can also choose which variable to display when visualizing the results.

In addition, tasks that modify variables provide new output options. You can return a table with all of
the variables, or with only the variables that were modified. For tasks that return logical arrays, you
can specify the size of the output. The size can match the size of the input table or a table containing
only the variables that were used in the calculation.

Clean Outlier Data Live Editor Task: Visualize results with a histogram
The Clean Outlier Data Live Editor task now offers histogram plots for most detection methods. The
histogram can summarize the input data, the outliers, the cleaned data with the outliers filled, and
the outlier detection thresholds and center value.

fillmissing Function: Specify custom fill method


You can now specify a custom method for filling missing values when using the fillmissing
function. Specify the custom method as a function handle.

normalize Function: Normalize multiple data sets with same


parameters
normalize can now return the centering and scaling parameter values used to perform the
normalization. You can reuse these parameters to normalize subsequent data sets in the same
manner. For example, you can normalize an array of data A and then normalize a second array B with
the same parameters:

[Anorm,C,S] = normalize(A);
Bnorm = normalize(B,'center',C,'scale',S);

The new outputs C and S contain the centering and scaling parameter values, respectively. So that
you can easily reuse them in a later normalization step, you can also now specify the 'center' and
'scale' normalization methods at the same time. These are the only two normalization methods that
you can specify together.

6-12
Data Analysis

To further support these changes, when method is 'center' or 'scale', the possible values of
methodtype now include arrays and tables. While these methodtype values are intended to work
with the new outputs C and S, you also can compute your own normalization parameters to specify.

groupcounts Function: Display percentages of group counts


groupcounts now displays information about the percentage each group count represents.

• For table and timetable inputs, groupcounts automatically displays the percentages represented
by each group count in the output table.
• For array inputs, groupcounts has a new third output argument to return the percentages
represented by each group count.

Compatibility Considerations
When groupcounts operates on data in a table or timetable, the output contains an additional table
variable for the percentages. The percentages are in the range [0 100] and are included in the table
variable Percent.

Any code that references specific table variables is unaffected. However, you might need to update
code that depends on the number of variables in the output table.

ts2timetable Function: Convert timeseries objects to timetables


To convert timeseries objects to timetables, use the ts2timetable function.

table and timetable Functions: Specify dimension names using the


'DimensionNames' name-value argument
When you create tables and timetables, you can specify their dimension names by using the
'DimensionNames' name-value argument with these functions:

• array2table
• array2timetable
• cell2table
• struct2table
• table
• timetable

In previous releases, you could change the dimension names only by creating a table or timetable and
then changing its DimensionNames property.

Functionality being removed or changed


Table dimension names cannot match reserved names
Behavior change

6-13
R2021a

MATLAB raises an error if you assign a dimension name that matches one of these reserved names:
'Properties', 'RowNames', 'VariableNames', or ':'. In previous releases, MATLAB raised a
warning and modified the dimension names so that they were different from the reserved names.

For example, if you create a table and then assign 'Properties' as a dimension name, the result is
an error.

T = array2table(magic(3));
T.Properties.DimensionNames = {'Rows','Properties'}

'SamplingRate' will be removed


Warns

The 'SamplingRate' name-value argument will be removed in a future release. Use 'SampleRate'
instead. The corresponding timetable property is also named SampleRate.

For backward compatibility, you still can specify 'SamplingRate' as the name of the name-value
argument. However, the value is assigned to the SampleRate property.

This change in behavior affects the timetable functions shown in the list:

• array2timetable
• retime
• synchronize
• table2timetable
• timetable

6-14
Data Import and Export

Data Import and Export


XML Files: Read, write, and import XML files using readtable,
readtimetable, and other functions
The readtable, writetable, readtimetable, writetimetable, and detectImportOptions
functions now support reading and writing XML files. This list outlines the added capabilities of each
function.

• readtable and readtimetable — Read XML data into MATLAB as a table or timetable. You can
specify optional name-value arguments to control how readtable and readtimetable treat
XML data. For example, specify ‘ImportAttributes’,false to ignore attribute nodes.
• writetable and writetimetable — Write a table or timetable in MATLAB to an XML file.
Specify optional name-value arguments to control how writetable and writetimetable treat
XML data. For example, specify ‘AttributeSuffix','_att' to specify that all table or
timetable variables with the suffix '_att' should be written as attributes in the output XML file.
• detectImportOptions — The detectImportOptions function now returns an
XMLImportOptions object when you call it on an XML file. Its behavior when you call it on other
file types has not changed. Use the XMLImportOptions object with readtable to customize
import options. For instance:

• Import only a subset of data using the SelectedVariableNames property.


• Specify the names and data types of the variables in the input file using the VariableNames
and the VariableTypes properties.
• Manage the import of specific nodes in the XML file using name-value arguments such as
'TableSelector', 'RowSelector', or 'VariableSelectors'.

For more information, see XMLImportOptions.

MATLAB API for Advanced XML Processing: Create, read, write,


transform, and query XML
Use the MATLAB API for XML Processing (MAXP) to develop advanced applications that create, read,
write, transform, and query XML documents. MAXP consists of these packages:

• matlab.io.xml.dom — Classes for creating, reading, and writing XML files and strings following
the W3C DOM standard.
• matlab.io.xml.transform — Classes for transforming XML documents from one type to
another following the XSLT 1.0 standard.
• matlab.io.xml.xpath — Classes for querying XML documents using XPath 1.0 expressions.

XML Files: Register XML namespace prefixes for evaluating XPath


expressions using readtable,readstruct, and other functions
Use the RegisteredNamespaces name-value argument to specify namespace prefixes that
readtable, readtimetable,readstruct, XMLImportOptions, and detectImportOptions use
when evaluating XPath expressions in an XML file. RegisteredNamespaces can be used when you
also evaluate an XPath expression specified by a selector name-value argument, such as
StructSelector for readstruct, or VariableSelectors for readtable and readtimetable.

6-15
R2021a

The readstruct function automatically detects namespace prefixes to register for use in XPath
evaluation, but you can also register new namespace prefixes using the RegisteredNamespaces
name-value argument. You might register a new namespace prefix when an XML node has a
namespace URL, but no declared namespace prefix in the XML file. In that case, you can specify
RegisteredNamespaces as a string array containing a namespace prefix and the associated URL.

For example, evaluate an XPath expression on an XML file named example.xml which does not
contain a namespace prefix declaration. Specify 'RegisteredNamespaces' as [“myprefix”,
“https://www.mathworks.com”] to assign the prefix myprefix to the URL https://
www.mathworks.com.

data = readstruct("example.xml", "StructSelector", "/myprefix:Data",...


"RegisteredNamespaces", [“myprefix”, “https://www.mathworks.com”])

In the resulting structure, the namespace prefix and URL will appear as attributes belonging to the
element specified in the StructSelector name-value argument.

Low-level file I/O functions and remote data: Perform read and write
operations on remotely stored files
You can now use low-level file I/O functions, such as fopen, fread, and fwrite, to work with files
stored in remote locations. Some supported remote locations include Amazon S3™ and Windows
Azure® Blob Storage.

When reading from or writing to a remote location, you must specify the full path using a uniform
resource locator (URL). For example, open a binary file from the Amazon S3 cloud.

fid = fopen(“s3://bucketname/path_to_file/example.bin”);

For more information on setting up MATLAB to access your online storage service, see Work with
Remote Data.

save and load functions and remote data: Save, load, and append
data to remotely stored v7.3 MAT-files
You can now access v7.3 MAT-files stored in remote locations, such as Amazon S3 and Windows Azure
Blob Storage, using the save and load functions.

When saving, loading, or appending data to a remote location, you must specify the full path using a
uniform resource locator (URL). For example, load a MAT-file from the Amazon S3 cloud.

load(“s3:://bucketname/path_to_file/example.mat”);

For more information on setting up MATLAB to access your online storage service, see Work with
Remote Data.

Reading Online Data: Read files over HTTP and HTTPS using
readtable, audioread, and other reading functions
Read files from an internet URL by specifying filename as a string that contains the protocol type
'http://' or 'https://'. This lets you read data from their primary online sources.

6-16
Data Import and Export

This functionality is supported by these functions: audioread, audioinfo, parquetread,


parquetinfo, readtable, readtimetable, readvars, readstruct, readmatrix, readcell,
readlines, and detectImportOptions.

Parquet Data Format: Use categorical data in parquet data format


Read, write, and analyze parquet data that contain the categorical data type.

This functionality is supported by these functions: parquetread, parquetwrite, parquetinfo,


and parquetDatastore.

Datastores: Read all data from a datastore using parallel processing


You can use parallel processing when reading all data from a datastore (requires Parallel Computing
Toolbox). Parallel processing results in improved performance when reading data, especially with
remote data.

Data Compression Functions: Improved functionality in zip/unzip and


tar/untar
On Windows, macOS, and Linux systems:

• zip can compress an individual file of any size.


• zip can compress any number of files in a single function call.
• tar can compress a group of files of any cumulative size.

Additionally, on Windows systems, unzip and untar replace invalid characters with underscores if
they occur in entry path names of the original file.

imfinfo function: Get information about all Adobe Digital Negative


(DNG) file tags
The imfinfo function returns information on all DNG file tags as individual named fields in the
output structure. For a complete list of DNG file tags, see Chapter 4 of the Adobe® Digital Negative
(DNG) Specification.

jsonencode: Add indentation to JSON text


Use the jsonencode 'PrettyPrint' option to display JSON text with an indentation of two spaces.

s.Width = 800;
s.Height = 600;
s.Title = 'View from the 15th Floor';
s.Animated = false;
s.IDs = [116, 943, 234, 38793];
jsonencode(s,'PrettyPrint',true)

ans =
'{
"Width": 800,
"Height": 600,

6-17
R2021a

"Title": "View from the 15th Floor",


"Animated": false,
"IDs": [
116,
943,
234,
38793
]
}'

Functionality being removed or changed


The H5I.get_name function only accepts named HDF5 datatypes as input arguments.
Behavior change

Starting in R2020a, the H5I.get_name function only accepts committed (previously called named)
HDF5 datatypes as input arguments, and will error if you pass other datatypes as input. In releases
R2019b and earlier, H5I.get_name does not error if you pass other datatypes as input.

To verify that the input is a committed HDF5 datatype, call the H5T.committed function on it. The
H5T.committed function returns a value of 1 if the input is a committed HDF5 datatype, and a value
of 0 if it is not.

imfinfo now returns Adobe DNG tags belonging to versions 1.2 through 1.5 in individual
named fields in the output structure
Behavior change

When you call the imfinfo function on an Adobe DNG file, it now returns tags belonging to versions
1.2 through 1.5 as individual named fields in the output structure. Previously, tags belonging to these
versions were stored in the 'UnknownTags' field of the output structure. For a complete list of DNG
file tags, see Chapter 4 of the Adobe Digital Negative (DNG) Specification.

imread reads the first frame in a GIF file by default


Behavior change

Starting in R2021a, when you read a GIF file without specifying additional arguments, the imread
function reads the first frame by default. Previously, imread read all the frames in the file by default.

To read all the frames in the order that they appear in the GIF file, specify the value of the 'Frames'
name-value argument as 'all'.

serial function will be removed


Still runs

serial and its object properties will be removed. Previously, serial and its object properties were
not recommended. Use serialport and its properties instead.

This example shows how to connect to a serial port device using the recommended functionality.

Functionality Use This Instead


s = serial("COM1"); s = serialport("COM1",115200);
s.BaudRate = 115200;
fopen(s)

6-18
Data Import and Export

See Transition Your Code to serialport Interface for more information about using the
recommended functionality.

6-19
R2021a

Mathematics

Graph Algorithms: Compute all paths, all cycles, and cycle basis
graph and digraph objects have new functions to compute paths and cycles:

• allpaths — Compute all paths between two nodes in a graph or digraph object.
• allcycles — Compute all cycles in a graph or digraph object.
• cyclebasis — Compute the fundamental cycle basis of a graph object.
• hascycles — Determine whether a graph or digraph object contains cycles.

griddedInterpolant Object: Use multivalued interpolation to


interpolate multiple data sets simultaneously
griddedInterpolant can now interpolate multiple data sets on the same grid at the same query
points. For example, if you specify a 2-D grid, a 3-D array of values at the grid points, and a 2-D
collection of query points, then griddedInterpolant returns the interpolated values at the query
points for each 2-D page in the 3-D array of values.

Previously, this functionality was available in interp1 for 1-D interpolation, but this improvement to
griddedInterpolant adds support for N-D multivalued interpolation.

eig Function: Improved algorithm for skew-Hermitian matrices


eig now has an improved algorithm for input matrices that are skew-Hermitian. With the function
call [V,D] = eig(A), where A is skew-Hermitian, eig now guarantees that the matrix of
eigenvectors V is unitary and the diagonal matrix of eigenvalues D is purely imaginary.

cdf2rdf Function: Improved algorithm for all inputs


cdf2rdf has an improved algorithm for all input matrices that reduces floating-point round-off errors
in the calculation.

Functionality being removed or changed


Line Continuation: Ellipsis following operator treated as a space
Behavior change

Previously, if an ellipsis followed an operator inside of a matrix or cell array, it caused the operator to
be treated as unary. Ellipses will now be treated as a space in all cases.

6-20
Mathematics

Old Behavior New Behavior


x = [1 -... x = [1 -...
2] 2]

x = x =
1 -2 -1

Previously, this code was equivalent to the Now, the ellipsis will be treated as a space so this
expression, x = [1 -2]. code is equivalent to the expression, x = [1 -
2].

6-21
R2021a

Graphics

Create Plot Live Editor Task: Create plots interactively and generate
code
The Create Plot Live Editor Task makes generating and exploring visualizations for data simple and
interactive. With this task you can select the data you wish to visualize and choose the plot type that
best represents that data. Alternatively, you can explore the visualizations available in MATLAB to
find the desired plot type and add your data. This task creates labels for the visualization based on
the data and can be used to add or adjust the optional parameters of the visualization.

bubblecloud Function: Visualize part-to-whole relationships


Use the bubblecloud function to illustrate the relationship between elements in your data set and
the set as a whole. For example, you can visualize data collected from different cities, and represent
each city as a bubble whose size is proportional to the value for that city.

tiledlayout Function: Control the tile indexing scheme


Control whether the tile indices increase across the rows or down the columns of a layout by setting
the TileIndexing property of a TiledChartLayout object. Select one of the following options:

• 'rowmajor' — Increment the tile indices across the first row before moving to the next row. This
is the default behavior.
• 'columnmajor' — Increment the indices down the first column before moving to the next
column. This indexing scheme is the same as linear indexing for arrays.

The nexttile function populates tiles according to the indexing scheme. If you change the tile
indexing of a populated layout, the tile positions change to match the new scheme.

6-22
Graphics

PolarAxes Objects: Use the CurrentPoint property or call ginput to get


the cursor location within polar axes
Query the CurrentPoint property of a PolarAxes object to get the location of the last click within
the axes. The ginput function also supports querying coordinates of polar axes.

Scatter Plots and Constant Lines: Create multiple scatter plots or


constant lines at once
• The scatter, polarscatter, and swarmchart functions now accept the same combinations of
matrices and vectors as the plot function does. As a result, you can visualize multiple data sets at
once rather using the hold function between plotting commands.
• The xline and yline functions now accept vectors of values for creating multiple vertical or
horizontal reference lines. You can also specify separate labels for each line using a string array or
a cell array.

Axis Limits: Define LimitsChangedFcn callback that executes when the


limits of an axis change
Define the LimitsChangedFcn callback function on any type of ruler object such as a numeric ruler.
The callback function executes when the limits of the corresponding axis change. For example, you
can define the callback in an app to update another aspect of the UI when the user pans within the
axes.

Axis Limits: Control axis limits


Control the axis limits for your plots by setting the XLimitMethod, YLimitMethod, or
ZLimitMethod on the axes. Select one of the following property values:

• 'tickaligned' — Align the edges of the axes box with the tick marks that are closest to your
data without excluding any data. This is the default option.

6-23
R2021a

• 'tight' — Fit the axes box tightly around the data by setting the axis limits equal to the range of
the data.
• 'padded' — Fit the axes box around the data with a thin margin of padding on each side. The
width of the margin is approximately 7% of your data range.

exportgraphics and copygraphics Functions: Specify RGB, CMYK, or


grayscale output
Choose a color space when exporting or copying graphics. Specify the Colorspace name-value
argument when you call the exportgraphics or copygraphics functions. Select one of the
following options:

• 'rgb' — Capture truecolor RGB content. This is the default color space.
• 'gray' — Convert the content to grayscale.
• 'cmyk' (exportgraphics only) — Convert the content to cyan, magenta, yellow, and black
(CMYK) before exporting the content as an EPS file.

colororder Function: Control colors in stacked plots


The colororder function now supports charts created with the stackedplot function.

Tick Labels: Automatically rotate tick labels


When you manually specify the ticks or the tick labels for a chart, the tick labels automatically rotate
to give the best possible presentation given the size of the figure and the number of the tick labels.

6-24
Graphics

patch and errorbar Functions: Expanded data type support


The patch and errorbar functions now support more data types:

• The patch function accepts numeric, datetime, duration, and categorical values for the x-, y-, and
z-coordinates.
• The errorbar function accepts numeric, datetime, duration, and categorical values for the x- and
y-coordinates. It also accepts numeric and duration values for the error bar lengths above, below,
and on either side of the data points.

Geographic Plots: Access basemaps using additional proxy server


authentication types
You can now access basemaps for geographic axes and charts using additional proxy server
authentication types.

• On Windows, you can use Basic, Digest, NTLM, Negotiate (SPNEGO), and Kerberos
authentication.
• On Linux and macOS, you can use Basic, Digest, and NTLM authentication.

Prior to R2021a, geographic axes and charts supported only types without authentication or with
Basic authentication. For more information about specifying proxy server settings, see Use MATLAB
Web Preferences For Proxy Server Settings.

Functionality being removed or changed


Tile spacing and padding options for tiled chart layouts have changed
Behavior change

6-25
R2021a

When you create a tiled chart layout, some of the TileSpacing and Padding properties provide a
different result or have new names.

The new TileSpacing options are 'loose', 'compact', 'tight', and 'none'. The new Padding
options are 'loose', 'compact', and 'tight'. The following tables describe how the previous
options relate to the new options.

TileSpacing Changes

Previous TileSpacing R2021a TileSpacing Option How to Update Your Code


Option
'normal' 'loose' Consider changing instances of
'normal' to 'loose'.

The 'normal' option is no


longer recommended, but it
continues to work, and there are
no plans to remove it.

'compact' 'compact' No changes needed.

6-26
Graphics

Previous TileSpacing R2021a TileSpacing Option How to Update Your Code


Option
Not Applicable 'tight' 'tight' is a new option. It
provides the same result as
'none' does in previous
releases.

'none' 'none' The 'none' option removes all


the space between adjacent plot
boxes, and the tick labels
overlap with neighboring plot
boxes.

To preserve the spacing


between the plot boxes, change
instances of 'none' to
'tight'.

Padding Changes

Previous Padding Option R2021a Padding Option How to Update Your Code
'normal' 'loose' Consider changing instances of
'normal' to 'loose'.

The 'normal' option is no


longer recommended, but it
continues to work, and there are
no plans to remove it.

6-27
R2021a

Previous Padding Option R2021a Padding Option How to Update Your Code
'compact' 'compact' No changes needed.

'none' 'tight' Consider changing instances of


'none' to 'tight'.

The 'none' option is no longer


recommended, but it continues
to work, and there are no plans
to remove it.

Passing an empty label to the legend function omits the entry from the legend
Behavior change

When you call the legend function and specify a label as an empty character vector, an empty string,
or an empty element in a cell array or string array, the corresponding entry is omitted from the
legend. In R2020b and earlier releases, the entry appears in the legend without a label.

For example, this code plots two sine waves and a reference line at y=0. Then it creates a legend with
three labels, where the last label is empty. In R2020b, the third line appears in the legend without a
label. In R2021a, the third line is omitted from the legend.

x = 0:0.2:10;
plot(x,sin(x),x,sin(x+1));
hold on
yline(0,'--')
legend('sin(x)','sin(x+1)','')

6-28
Graphics

To keep an entry in the legend without a label, include a space character in the label. For example, to
update the preceding code, specify the last label as a character vector containing a space (' ').
legend('sin(x)','sin(x+1)',' ')

Alternatively, if you do not want to display a space character, you can pass the individual line objects
to the legend function with an array of labels. To get the individual line objects, call each plotting
function with an output argument.
x = 0:0.2:10;
p = plot(x,sin(x),x,sin(x+1));
hold on
line0 = yline(0,'--');
legend([p(1) p(2) line0], {'sin(x)','sin(x+1)',''});

The XData, YData, and ZData properties on Patch objects created with the fill and fill3
functions return values of the original data type
Behavior change

The XData, YData, and ZData properties on a Patch object created by the fill or fill3 functions
return the coordinates using the original input data type, rather than returning them as double
values.

In previous releases, datetime, duration, and categorical coordinates are converted to double values
when they are stored in the XData, YData, and ZData properties.

For example, this code creates a filled polygon with datetime x-coordinates. Then it calculates x2
using the values stored in the XData property. In R2020b, h.XData and x2 are double arrays. In
R2021a, h.XData and x2 are datetime arrays.
x = datetime('01-Jan-2018') + days([0 1 1 0]);
y = [0 0 1 1];
h = fill(x,y,'red');
x2 = h.XData + 1;

To preserve the double values in your code, get the double values from the Vertices property of
the Patch object. The x-, y-, and z-coordinates are stored as double values in the first, second, and
third columns of the Vertices array.
x2 = h.Vertices(:,1) + 1;

6-29
R2021a

Alternatively, use the ruler2num function. Pass the coordinate values and the corresponding axis
ruler to the ruler2num function.

ax = gca;
x2 = ruler2num(h.XData,ax.XAxis) + 1;

Graphics objects and UI components sized using 'points', 'inches', and 'centimeters' units
will increase in size on macOS platforms
Behavior change in future release

In a future release, graphics and UI objects that have Units or FontUnits properties set to
'points', 'inches', or 'centimeters' will use a conversion value of 1 pixel = 1/96th inch on
macOS platforms. The current conversion value is 1 pixel = 1/72nd inch. As a result, these objects
and text elements will display 1.33 times larger than their previous size. This change will provide a
more readable default font size and will ensure a consistent object size across Windows and macOS
platforms.

The following objects use a unit value of 'pixels' by default and will not be affected by this change:

• UI components in App Designer or in apps created with the uifigure function


• UI components in apps created in GUIDE and migrated to App Designer using the GUIDE to App
Designer Migration Tool for MATLAB
• Axes objects created using the uiaxes function

For the most control when sizing and laying out your graphics objects and UI components, use a
value of 'pixels' for Units and FontUnits properties. To maintain object sizes in current and
future releases, make these updates in your code:

• Objects with Units or FontUnits set to 'points' — Update the value of the property from
'points' to 'pixels'.
• Objects with Units or FontUnits set to 'inches' — Update the value of the property from
'inches' to 'pixels' and multiply all Position values by 72.
• Objects with Units or FontUnits set to 'centimeters' — Update the value of the property
from 'centimeters' to 'pixels' and multiply all Position values by 72/2.54.

For example, this code creates a push button in a figure window, with its position specified in inches:

uicontrol('Units','inches','Position',[0.6 0.1 1.75 0.5]);

In a future release, the push button created by this code will display 1.33 times larger on macOS
platforms. To maintain the size and position of the push button in current and future releases, update
the code to:

uicontrol('Units','pixels','Position',[50 10 126 36]);

Align Distribute Tool will be removed in a future release


Warns

The Align Distribute Tool will be removed in a future release.

To control the arrangement of multiple plots in a figure, create a tiled chart layout using the
tiledlayout function instead.

6-30
Graphics

To align or distribute graphics objects within a figure, select Tools > Align or Tools > Distribute
from the figure toolbar instead.

6-31
R2021a

App Building

uihyperlink Function: Add and configure clickable links in apps and on


the App Designer canvas
To create a link, call the uihyperlink function or, in App Designer, drag a hyperlink UI component
from the Component Library onto the canvas.

Hyperlink UI components are supported only in App Designer apps and in figures created with the
uifigure function.

uitree Function: Add and configure check box trees in apps and on the
App Designer canvas
A check box tree is a styled with check boxes to the left of every item. You can now create check box
trees in apps and on the App Designer canvas. Check box trees allow for easier selection of multiple
tree nodes.

In apps created programmatically with the uifigure function, create a check box tree using the
uitree function by specifying the style 'checkbox'.

In App Designer, create a check box tree by dragging it from the Component Library onto the
canvas.

Interpreter Property: Style text and display equations in labels with


HTML and LaTeX markup
Use the Interpreter property on Label objects (created with the uilabel function) to enable
markup in the label text. To add HTML markup, set the Interpreter property to 'html'. To add
LaTeX markup, set the Interpreter property to 'latex'.

For more information, see Label Properties.

WindowStyle Property: Create UI figures that remain in the


foreground
To keep a specific UI figure window in front of other windows, set the WindowStyle property to
'alwaysontop'. Unlike modal figures, UI figure windows with this property setting do not restrict
keyboard and mouse interactions.

The 'alwaysontop' property value is available only in figures created using the uifigure function.

For more information, see UI Figure Properties.

scroll Function: Scroll to a location within a table UI component


programmatically
Use the scroll function to scroll within a table UI component programmatically. Specify the scroll
location as the top, bottom, left, or right side of the table, or as a specific row, column, or table cell.

6-32
App Building

UI Component Accessibility: Select ListBox items, Table cells,


ColorPicker colors, and DatePicker menus using the keyboard
You can now use keyboard shortcuts to change the focus and make selections in various UI
components. These shortcuts are supported for components in figures created using
the uifigure function.

Component Action Keyboard Shortcut


ListBox with Multiselect Toggle list box selection. Space
property set to 'off'
ListBox with Multiselect Select all items. Ctrl+A
property set to 'on' Move focus to previous item and Shift+Up
toggle selection.
Move focus to next item and Shift+Down
toggle selection.
Move focus to previous item Ctrl+Up
without toggling selection.
Move focus to next item without Ctrl+Down
toggling selection.
Toggle selection of item Ctrl+Space
currently in focus.
Table Select table cell in top-left Ctrl+Home
corner.
Select table cell in bottom-right Ctrl+End
corner.
ColorPicker gradient selector Move gradient selector. Arrow keys
ColorPicker hue slider Move hue slider. Up and Down
DatePicker Cycle between drop down Tab
menus, buttons, and calendar.

App Designer: Use custom UI components in App Designer


You can now configure custom UI component classes to appear in the App Designer Component
Library and to be used interactively in Design View.

To configure a custom UI component class for use in App Designer, follow these steps:

• Define your own UI component class by creating a subclass of the


matlab.ui.componentcontainer.ComponentContainer base class.
• Call the appdesigner.customcomponent.configureMetadata function and specify the path
to the component class .m file.
• Use the resulting dialog box to configure the metadata associated with the component, including
the component name, icon, author, and category.

This creates a resources folder with the App Designer metadata. To view the component in the App
Designer Component Library, add the folder containing the component class file and the generated
resources folder to the MATLAB path.

6-33
R2021a

To share your custom UI component for others to use in App Designer, share both the component
class file and the resources folder.

For more information, see Configure Custom UI Components for App Designer.

App Designer: Zoom and pan in the canvas, and zoom in the Code
View editor
To zoom in or out in the App Designer canvas and in the Code View editor, hold Ctrl and move the
scroll wheel, or press Ctrl+Plus and Ctrl+Minus. To return to the default scale, press Ctrl+Alt+0.
Zooming does not affect the Component Library, Component Browser, or Code Browser.

To pan in the App Designer canvas, use one of the following:

• Click and drag with the middle mouse button.


• Hold Space while clicking and dragging with the left mouse button.

Compatibility Considerations
In previous releases, the Ctrl+Plus and Ctrl+Minus keyboard shortcuts zoomed the entire App
Designer desktop.

App Designer: Control color and tab settings in Code View using
MATLAB preferences
Color and tab preferences applied to the MATLAB Editor are now also applied to the App Designer
Editor.

Additionally, you can now change the background color of the App Designer read-only code. Access
this setting in the App Designer tab of MATLAB preferences.

For more information, see Personalize Code View Appearance.

App Designer: Customize split-screen layouts in the App Designer


editor
To view your document in horizontal or vertical split-screen mode in the App Designer Code View
editor, select a layout in the App Designer toolstrip.

App Testing Framework: Perform gestures on panels and tables


The app testing framework supports gestures on more UI components:

• Perform press, hover, and chooseContextMenu gestures on panels.


• Perform choose, type, and chooseContextMenu gestures on table UI components.

6-34
App Building

App Testing Framework: Close alert dialog box in front of figure


window
You can now use the dismissAlertDialog method as part of a test case to programmatically close
an alert dialog box in front of a figure window. For example, create a modal alert dialog box and close
it by calling the method.

fig = uifigure;
uialert(fig,'File not found','Invalid File')

tc = matlab.uitest.TestCase.forInteractiveUse;
tc.dismissAlertDialog(fig)

Web Apps and Standalone Applications: Datatips supported in


graphics
Graphics created in web apps and standalone applications support datatips. Use datatips in these
applications just as you would in MATLAB figures.

Functionality Being Removed or Changed


GUIDE will be removed in a future release
Warns

The GUIDE environment and the guide function will be removed in a future release.

After GUIDE is removed, existing GUIDE apps will continue to run in MATLAB but will not be editable
using the drag-and-drop GUIDE environment. To continue editing an existing GUIDE app and help
maintain its compatibility with future MATLAB releases, use one of the suggested migration
strategies listed in the table.

App Development Migration Strategy How to Migrate


Frequent or ongoing Migrate your app to App Use the GUIDE to App Designer
development Designer. Migration Tool for MATLAB on
mathworks.com.
Minimal or occasional editing Export your app to a single Open the app in GUIDE and
MATLAB file to manage your select File > Export to
app layout and code using MATLAB-file.
MATLAB functions.

To create new apps, use App Designer and the appdesigner function instead. App Designer is the
recommended app development environment in MATLAB.

To learn more about migrating apps, see GUIDE Migration Strategies.

For more information about App Designer, go to Comparing GUIDE and App Designer on
mathworks.com.

GUIDE templates have been removed

6-35
R2021a

All GUIDE templates other than the blank GUI have been removed. To create new apps interactively,
use App Designer and the appdesigner function instead.

Graphics objects and UI components sized using 'points', 'inches', and 'centimeters' units
will increase in size on macOS platforms
Behavior change in future release

In a future release, graphics and UI objects that have Units or FontUnits properties set to
'points', 'inches', or 'centimeters' will use a conversion value of 1 pixel = 1/96th inch on
macOS platforms. The current conversion value is 1 pixel = 1/72nd inch. As a result, these objects
and text elements will display 1.33 times larger than their previous size. This change will provide a
more readable default font size and will ensure a consistent object size across Windows and macOS
platforms.

The following objects use a unit value of 'pixels' by default and will not be affected by this change:

• UI components in App Designer or in apps created with the uifigure function


• UI components in apps created in GUIDE and migrated to App Designer using the GUIDE to App
Designer Migration Tool for MATLAB
• Axes objects created using the uiaxes function

For the most control when sizing and laying out your graphics objects and UI components, use a
value of 'pixels' for Units and FontUnits properties. To maintain object sizes in current and
future releases, make these updates in your code:

• Objects with Units or FontUnits set to 'points' — Update the value of the property from
'points' to 'pixels'.
• Objects with Units or FontUnits set to 'inches' — Update the value of the property from
'inches' to 'pixels' and multiply all Position values by 72.
• Objects with Units or FontUnits set to 'centimeters' — Update the value of the property
from 'centimeters' to 'pixels' and multiply all Position values by 72/2.54.

For example, this code creates a push button in a figure window, with its position specified in inches:

uicontrol('Units','inches','Position',[0.6 0.1 1.75 0.5]);

In a future release, the push button created by this code will display 1.33 times larger on macOS
platforms. To maintain the size and position of the push button in current and future releases, update
the code to:

uicontrol('Units','pixels','Position',[50 10 126 36]);

6-36
Performance

Performance

Sparse Matrix Multiplication: Improved performance multiplying large


sparse matrices
Matrix multiplication performance has improved when multiplying sparse matrices. The performance
improvement arises from added support for multithreading in the operation, and therefore the
speedup gets better as the matrix size and number of nonzeros increase.

For example, if you multiply two 1e5-by-1e5 random sparse matrices with approximately two million
nonzeros, performance in R2021a is about 4.4x faster than in R2020b on a machine with 6 physical
cores.

function timingSparseMult
rng default
A = sprand(1e5,1e5,0.0002);
B = sprand(1e5,1e5,0.0002);
tic
C = A*B;
toc
end

The approximate execution times are:

R2020b: 2.2 s

R2021a: 0.5 s

The code was timed on a Windows 10, Intel Xeon W-2133 CPU @ 3.60 GHz test system by calling the
function timingSparseMult.

Sparse Linear Systems: Improved performance solving sparse linear


systems A*X = B with multicolumn B
Solving a linear system of the form A*X = B by executing X = A\B shows improved performance
when A is a sparse square matrix and B is a matrix with two or more columns. The speedup applies to
the solving step of the calculation but not the factorization step. The performance improvement arises
from added support for multithreading, and therefore the speedup gets better as the number of
columns in B increases.

For example, if you solve A*X = B using a 1e4-by-1e4 sparse coefficient matrix with approximately
40,000 nonzeros and a B matrix with 100 columns, performance in R2021a is about 5x faster than in
R2020b on a machine with 6 physical cores. This code uses decomposition to factor the coefficient
matrix, so only the solving process is timed. If you use X = A\B instead, you still see a speedup, but
the time required to factor the matrix is included and has not changed.

function timingSparseBackslashMultRHS
rng default
A = sprand(1e4,1e4,0.0003) + speye(1e4);
B = sprand(1e4,100,0.002);
dA = decomposition(A);
tic
x = dA\B;

6-37
R2021a

toc
end

The approximate execution times are:

R2020b: 1.5 s

R2021a: 0.3 s

The code was timed on a Windows 10, Intel Xeon W-2133 CPU @ 3.60 GHz test system by calling the
function timingSparseBackslashMultRHS.

vecnorm Function: Improved performance operating on data with


multiple columns
The performance of the vecnorm function has improved for all norm types when the data has 16 or
more columns and at least 217 elements.

The improvement also applies to N-D array data that can be permuted into a matrix with the requisite
number of columns. The speedup varies depending on the type of norm being calculated.

For example, if you calculate the 2-norm of a 1000-by-1000-by-3 array along the third dimension,
performance in R2021a is about 7.3x faster than in R2020b.

function timingVecnorm
rng default
N = 1000;
A = rand(N,N,3);
for k = 1:200
D = vecnorm(A,2,3);
end
end

The approximate execution times are:

R2020b: 8.8 s

R2021a: 1.2 s

The code was timed on a Windows 10, Intel Xeon W-2133 CPU @ 3.60 GHz test system using the
timeit function:

timeit(@timingVecnorm)

ismember Function: Improved performance for cell inputs


The ismember function shows improved performance operating on cell inputs. The speedup
depends on the size and layout of the data, with the largest speedup when the input has many cells
that contain few elements in each cell.

For example, if you use ismember to compare two 1000-by-1 cell arrays with 10 elements in each
cell, performance in R2021a is about 4.7x faster than in R2020b.

function timingIsmember
a = num2cell(char(randi(127,[1000 10])),2);

6-38
Performance

b = num2cell(char(randi(127,[1000 10])),2);
tic
for ii = 1:1e4
ismember(a,b);
end
toc
end

The approximate execution times are:

R2020b: 6.6 s

R2021a: 1.4 s

The code was timed on a Windows 10, Intel Xeon W-2133 CPU @ 3.60 GHz test system by calling the
function timingIsmember.

unique Function: Improved performance for numeric, logical, char, and


cell inputs
The unique function shows improved performance operating on numeric, logical, char, and cell
inputs. The speedup generally gets better as the size of the inputs increases, and the improvement
applies when using any optional flags except the 'legacy' flag.

For example, if you operate on a 100-by-1 cell array with 10 elements in each cell, performance in
R2021a is about 3.3x faster than in R2020b.
function timingUniqueCell
a = num2cell(char(randi(127,[100 10])),2);
tic
for ii = 1:1e5
b = unique(a);
end
toc
end

The approximate execution times are:

R2020b: 3.9 s

R2021a: 1.2 s

Also, if you use unique on a numeric input with 10,000 elements and specify three outputs with the
'stable' option, performance in R2021a is about 3.5x faster than in R2020b.
function timingUniqueNumeric
a = rand(10000,1);
tic
for ii=1:1e4
[C,ia,ic] = unique(a,'stable');
end
toc
end

The approximate execution times are:

R2020b: 9.4 s

6-39
R2021a

R2021a: 2.7 s

In both cases, the code was timed on a Windows 10, Intel Xeon W-2133 CPU @ 3.60 GHz test system
by calling the functions timingUniqueCell and timingUniqueNumeric.

Graph Functions: Improved performance modifying node and edge


lists
graph and digraph functions that modify the node and edge lists of the graph show improved
performance. This applies to the functions addedge, rmedge, addnode, rmnode, subgraph, and
reordernodes. The improvement applies to graphs that have no node properties (or only node
names), and graphs with no edge properties (or only edge weights). The improvement is most
noticeable when one of these functions is called many times in a loop, and the largest improvement
applies to graphs that have both node names and edge weights.

For example, if you use addedge in a loop to add new edges with node names and edge weights to an
empty graph, performance in R2021a is about 13x faster than in R2020b.

function timingAddedge
names = string(('A':'Z')') + (1:10);
names = names(1:100);
rng default
g = graph;
for ii = 1:1e3
g = addedge(g, names(randi(100)), names(randi(100)), randn);
end
end

The approximate execution times are:

R2020b: 2.6 s

R2021a: 0.2 s

The code was timed on a Windows 10, Intel Xeon W-2133 CPU @ 3.60 GHz test system by using the
timeit function:

timeit(@timingAddedge)

Axes Toolbar: Appears without delay when axes are ready


Prior to R2021a, when hovering the cursor over figure axes, there was delay before the axes toolbar
appeared. Now the toolbar will appear as soon as the axes are ready.

Rearranging UI Components: Improved performance when rearranging


UI components in a UI figure
Programmatically rearranging existing UI components in a figure created with the uifigure
function shows improved performance.

For example, if you sort 50 panels within a grid layout, performance in R2021a is approximately 1.9x
faster than in R2020b.

6-40
Performance

function timingSortComp
% Create components
panels = {};
fig = uifigure;
g = uigridlayout(fig,[1,1],'RowHeight',40);
g.Scrollable = true;
num = 50;
for i = 1:num
p = uipanel(g);
uilabel(p,'Text',['Panel ', num2str(i)],'Position',[10 10 70 22]);
g.RowHeight{end} = 40;
panels{end+1} = p;
end
drawnow;

% Rearrange components
tic
order = length(panels):-1:1;
for i = 1:length(order)
panels{i}.Layout.Row = order(i);
end
drawnow;
toc
end

The approximate execution times are:

R2020b: 0.70 s

R2021a: 0.36 s

The code was timed on a Windows 10, Intel Xeon E5-1650 CPU @ 3.60 GHz test system by calling the
function timingSortComp.

UI Figure Interactions: Faster responses to scroll, pointer movement,


and resize interactions in UI figures
In figures created with the uifigure function, the following interactions have improved
performance:

• Scrolling in a figure with a WindowScrollWheelFcn callback or an object with a predefined


scroll behavior
• Resizing a visible figure with a SizeChangedFcn callback or an object with a predefined resize
behavior
• Moving the mouse pointer in a figure with a WindowButtonMotionFcn callback when the figure
contains any UI components except axes components

This performance increase is more noticeable when using a trackpad to interact with the figure.

For example, scrolling to zoom in on the plot created by the code below is smoother and more
responsive in R2021a than in R2020b.

t1 = datetime(2019,1,1);
t2 = datetime(2020,1,1);
dates = linspace(t1,t2,10000);
data = rand(10000,10);
fig = uifigure;
stackedplot(fig,dates,data);

6-41
R2021a

On a Windows 10, Intel Xeon W-2133 CPU @ 3.60 GHz test system, the responses to the scroll action
are:

R2020b: When you zoom in on the plot by scrolling for approximately two seconds, the plot has
about a five second delay in completing the zoom animation.

R2021a: The zoom animation completes immediately after you finish the scroll action.

Plots in Apps: Improved performance for polar plots, volume


visualizations, plots with more than 16 axes, and older systems
Displaying polar plots, volume visualizations, or more than 16 axes in an app have improved
performance. The improvement affects plots displayed in apps:

• Plots that are displayed in an app created with App Designer


• Plots displayed in a figure created with the uifigure function

Systems with older graphics drivers might experience the improvement for all types of plots that are
created within the apps and figures listed above. For example, Intel drivers earlier than version
10.0.0.0 for Windows systems will experience additional improvements.

This code creates a polar plot and executes a for loop that changes the theta values at every
iteration. The for loop executes about 2x faster than in R2020b.

function timingPolar
f = uifigure;
pax = polaraxes('parent',f);
theta = 0:0.01:2*pi;
rho = sin(2*theta).*cos(2*theta);
pp = polarplot(pax, theta,rho);
pax.FontSize = 12;
drawnow

tic;
for i=1:100
pp.ThetaData = pp.ThetaData + .02*pi;
drawnow
end
toc
end

The approximate execution times are:

R2020b: 10.15 s

R2021a: 5.30 s

The code was timed on a Windows 10, Intel Xeon W-2133 CPU @ 3.60 GHz test system by calling the
function timingPolar.

6-42
Performance

Plots in Apps: Improved performance for plots with large numbers of


markers
Performance is improved for modifying certain types of plots in apps. You can observe the
improvement when the following conditions are true:

• The plots are displayed in an App Designer app, or they are displayed in a figure created with the
uifigure function.
• Your system is running a locally installed version of MATLAB on a modern Windows or macOS
system.
• You run the code either from the MATLAB command window or within a program file (.m file).

Note that plots created in live scripts do not show this improvement.

The plots typically contain large numbers of markers, and your code updates an aspect of those
markers, such as their positions. The improvement is more significant as you increase the number of
markers. For example, if you create a scatter plot with 10 million markers, and change the marker
positions 10 times, the performance in R2021a is about 1.3x faster than in R2020b.
function timingScatter
f = uifigure;
a = axes(f);
x = rand(1e7, 2);
s = scatter(a,x(:,1),x(:,2),'Marker','*');
drawnow;

tic;
for i=1:10
x = rand(1e7,2);
s.XData = x(:,1);
s.YData = x(:,2);
drawnow
end
toc
end

The approximate execution times are:

R2020b: 19.43 s

R2021a: 14.88 s

The code was timed on a macOS 10.14.6, Intel Core i9 CPU @ 3.60 GHz test system by calling the
function timingScatter.

Live Editor: Improved performance when saving large live scripts or


functions
When saving large live scripts or functions, you can continue using the Live Editor sooner in R2021a
than in R2020b. While you continue to use the Live Editor, MATLAB saves the file in the background.
When MATLAB finishes saving the file, the asterisk (*) next to the file name disappears, indicating
that the file is saved.

For example, on a Windows 10, Intel Xeon E5-1650 CPU @ 3.60 GHz test system, if you save a live
script containing 35,000 lines of code and then click the title bar of another document open in the

6-43
R2021a

Live Editor, MATLAB immediately switches to the other open document. In R2020b, there is a
noticeable delay before MATLAB switches to the other open document.

6-44
Software Development Tools

Software Development Tools

Projects: List all referenced projects of the current project


You can now use listAllProjectReferences to programmatically list all projects in the reference
hierarchy of a specified project.

Projects: List impacted project files


You can now use listImpactedFiles to programmatically list all project files impacted by changes
to a specified file.

Dependency Analyzer: Find required add-ons


Starting in R2021a, the Dependency Analyzer detects and lists required add-ons, including apps and
toolboxes, for the whole project or for selected files. The Dependency Analyzer might not detect
required support packages. For more details, see Find Required Products and Add-Ons.

Unit Testing Framework: Create test runners using alternative syntax


You can now use the testrunner function to create a runner for tests authored using the MATLAB
unit testing framework or Simulink Test™. In previous releases, you can explicitly create a runner
only by calling one of the static methods of the matlab.unittest.TestRunner class.

Use the testrunner function to create a default runner, a minimal runner with no plugins installed,
or a runner configured for text output. For example, create a default runner to run the tests in a test
class.

suite = testsuite('MyTestClass');
runner = testrunner;
results = run(runner,suite);

Unit Testing Framework: Initialize parameterization properties at suite


creation time
Starting in R2021a, you can specify parameterization properties that do not have a default value. This
feature is useful when parameters cannot be determined at the time MATLAB loads the test class
definition. To initialize a parameterization property at test suite creation time, use a static method
with the TestParameterDefinition attribute. For more information, see Define Parameters at
Suite Creation Time.

Unit Testing Framework: Run tests in parallel on thread-based pool


You can now run your tests on a thread-based parallel pool (requires Parallel Computing Toolbox). To
run tests using thread workers, start a thread-based pool and then call the runInParallel method
or the runtests function with the UseParallel name-value pair argument.

Thread-based parallel pools support only a subset of MATLAB and testing framework functionality.
For more information, see runInParallel or runtests.

6-45
R2021a

Unit Testing Framework: Run tests in MATLAB Online interactively


Starting in R2021a, you can run tests in MATLAB Online interactively. When you open a .m file
defining a function-based or class-based test in MATLAB Online, the toolstrip lets you run all tests in
the file or run the current test in the file. Also, you can customize the test run with options, such as
running tests in parallel (requires Parallel Computing Toolbox) or running tests with a specified level
of output detail.

The Run Tests section in the Editor tab of the toolstrip provides an alternative to programmatically
running tests with the runtests function. For more information, see Run Tests in Editor.

App Testing Framework: Perform gestures on panels and tables


The app testing framework supports gestures on more UI components:

• Perform press, hover, and chooseContextMenu gestures on panels.


• Perform choose, type, and chooseContextMenu gestures on table UI components.

App Testing Framework: Close alert dialog box in front of figure


window
You can now use the dismissAlertDialog method as part of a test case to programmatically close
an alert dialog box in front of a figure window. For example, create a modal alert dialog box and close
it by calling the method.

fig = uifigure;
uialert(fig,'File not found','Invalid File')

tc = matlab.uitest.TestCase.forInteractiveUse;
tc.dismissAlertDialog(fig)

Functionality being removed or changed


Character data is not supported in custom examples demos.xml file
Behavior change

Starting in R2021a, when creating custom examples, character data is not supported in the
description of the demos.xml file. If you have a demos.xml file that contains character data such as
&lt;, &gt;, &apos;, &quot;, and &amp;, the description does not appear correctly in the Help
browser.

To patch an existing demos.xml that contains character data, use the patchdemoxmlfile function.
patchdemoxmlfile patches the specified demos.xml file, replacing character data with non-
character data.

For example, patch the demos.xml file in the folder D:\Work\mytoolbox\help:

patchdemoxmlfile D:\Work\mytoolbox\help

6-46
External Language Interfaces

External Language Interfaces

C++ Interface: Support for C++ language features


The C++ interface supports these additional C++ language features.

• Support for std::vector values containing std::string values and C++ arrays containing C-
style strings. For more information, see String and Character Types in the C++ to MATLAB Data
Type Mapping topic.
• Support for void* values as input and output arguments. For more information, see Use void*
Arguments, void* Argument Types, and addOpaqueType.
• Pass C++ functions to function pointers. For more information, see Use Function Type Arguments
and addFunctionType.
• Support for function and member function template instantiations. Publishers can modify function
names. For more information, see Customize Function Template Names.

C++ Interface: Publisher options and analysis


The C++ interface supports these build configuration features.

• Generate an interface from header and source (.cpp) files. Pass a .cpp or .hpp file in the
clibgen.generateLibraryDefinition SourceFiles argument.
• Generate an interface from a header and a .dll file for Microsoft Visual Studio compilers. Pass
a .dll file in the clibgen.generateLibraryDefinition LibraryFiles argument.
• Improved troubleshooting messages.

Java Packages to be removed


Java packages and subpackages that currently ship with MATLAB will not be available in MATLAB in
a future release.

Compatibility Considerations
To continue using a Java package, install its JAR file and add the JAR file to the static path in MATLAB
using the instructions in Static Path.

Java Engine: MATLAB value object support


To work with MATLAB value objects in a Java engine application, use the
com.mathworks.matlab.types.ValueObject class in the Java Engine API Summary. You can
create a value object in MATLAB, return it to Java, and call its methods. For information about
mapping Java data types to MATLAB data types, see Java Data Type Conversions.

Python Interface and Engine: Version 3.6 support discontinued


Support for Python version 3.6 is discontinued.

6-47
R2021a

Compatibility Considerations
To ensure continued support for your applications, upgrade to a supported version of Python, either
version 3.7 or 3.8. For more information, see Versions of Python Compatible with MATLAB Products
by Release.

Perl 5.32.0: MATLAB support on Windows


As of R2021a, MATLAB on Windows ships with an updated version of Perl, version 5.32.0.

• See www.perl.org for a standard distribution of Perl, Perl source, and information about using
Perl.
• See https://metacpan.org/pod/HTML::Parser for a standard distribution of HTML::Parser, source
code, and information about using HTML::Parser.
• See https://metacpan.org/pod/HTML::Tagset for a standard distribution of HTML:Tagset, source
code, and information about using HTML:Tagset.

Compatibility Considerations
If you use the perl command on Windows platforms, see www.perl.org for information about using
this version of the Perl programming language.

6-48
Hardware Support

Hardware Support

Support added for IMU sensors


The MATLAB Support Package for Raspberry Pi Hardware now provides code generation and
connected IO support to Raspberry Pi functions for the these IMU sensors:

• HTS221
• LPS22HB
• LSM303C
• LSM6DSL
• LSM9DS1
• MPU-6050
• MPU-9250

New functionalities added to Raspberry Pi Resource Monitor app


The Raspberry Pi Resource Monitor App from the MATLAB Support Package for Raspberry Pi
Hardware has been improved to:

• Display peripherals used in a MATLAB or Simulink application deployed on the Raspberry Pi


hardware
• Enable or disable peripherals
• Check for missing libraries and packages
• Display all processes currently running on the Raspberry Pi hardware

6-49
7

R2020b

Version: 9.9

New Features

Bug Fixes

Compatibility Considerations
R2020b

Environment

MATLAB Online Accessibility: Use a screen reader to interact with the


Command Window and create scripts and functions
In MATLAB Online, you can use a screen reader to interact with the Command Window, create and
edit scripts and functions in the Editor, and navigate through the MATLAB desktop tools. Using a
screen reader is not supported in the Live Editor.

For more information, see Use a Screen Reader in MATLAB Online.

Live Editor Images: Add alternative text to images


You can add alternative text to an image in a live script or function to make it accessible to
individuals using a screen reader. To add alternative text, right-click the image and select Edit
Image... from the context menu. Add text to the Alt Text edit field.

Live Editor Images: Change the size of images


To change the size of an image in a live script or function, right-click the image and select Edit
Image... from the context menu. Then, to specify a size relative to the original image size, select
Relative (%) and specify the width and height of the image as a percentage of the original image. To
specify an absolute size, select Absolute (px) and specify the width and height of the image in pixels.
To return to the original image size, right-click the image and select Reset Image.

Live Editor Hyperlinks: Navigate to existing files from a live script or


live function using links
Use hyperlinks to navigate to existing files from a live script or live function. To insert a hyperlink to
an existing file, select the text to link in the current file, go to the Insert tab, and click
Hyperlink. Edit your display text (optional), select Existing File, and then enter or browse for the
file path.

For more information about adding hyperlinks into live scripts and live functions, see Format Files in
the Live Editor.

Live Editor Export: Export all live scripts and live functions in a folder
to a standard format
You can export all of the live scripts and live functions in a folder to a standard format. Available
formats include PDF, Microsoft Word, HTML, and LaTeX. To export the contents of a folder, on the
Live Editor tab, select Save > Export Folder.... Then, specify the export format, the location of the
folder to be exported, and the location for the exported files.

7-2
Environment

For more information about exporting live scripts and live functions, see Share Live Scripts and
Functions.

matlabRelease Object: Query MATLAB Release Information


matlabRelease is a new object that makes it possible to quickly query the MATLAB information of
your system. isMATLABReleaseOlderThan will allow you to determine if your current MATLAB
release is older than a specified release. Use these functions to quickly verify release versions.

Query Parallel Functionality: Determine if support for Parallel


Computing Toolbox functionality is available
You can now query if support for GPU and parallel pool functionality is available in your MATLAB
installation using the following functions:

• canUseGPU
• canUseParallelPool

Use these functions to check supported functionality and avoid executing code that relies on specific
hardware constraints.

Comparison Tool: Compare text files in MATLAB Online


Starting in R2020b, you can compare text files in MATLAB Online using the visdiff function. To
compare text files, in the Command Window, type:

visdiff('filename1.m','filename2.m');

MATLAB Drive: Decreased password confirmation requests in MATLAB


Drive Connector
Decreased password confirmation requests in MATLAB Drive Connector.

7-3
R2020b

MATLAB Drive: Faster shut down of MATLAB Drive Connector when


syncing is in progress
When syncing is in progress, MATLAB Drive Connector shuts down faster than in previous versions.

MATLAB Drive: Integration with OS-specific password management


systems
MATLAB Drive Connector now integrates with OS-specific password management systems.

MATLAB Drive: MATLAB Drive Connector available in Japanese


MATLAB Drive Connector is now available in Japanese.

MATLAB Drive: Download folders from MATLAB Drive online to your


desktop (December 2020)
You can now download folders in addition to downloading individual files from MATLAB Drive online.
To download a folder, in MATLAB Drive online, click the Download button or right-click the folder
and select Download.

For more information, see “Access Files in Your MATLAB Drive”

MATLAB Drive: Preview the contents of a shared folder in MATLAB


Drive online before accepting invitation (December 2020)
When you receive an invitation or a link to a shared folder, you can now navigate the structure of the
shared folder and preview individual files in MATLAB Drive online before accepting the invitation.

For more information, see “Share Folders Using MATLAB Drive”.

7-4
Language and Programming

Language and Programming

pattern Object and Functions: Match patterns in text functions


Pattens are an intuitive alternative to regular expressions for matching patterns in text. Pattern
functions can be combined together in expressions in order to build complex patterns that can then
be used as inputs for text-searching functions. For instance, to define a pattern for MATLAB release
names, which start with "R", followed by the four-digit year, and then either "a" or "b":

pat = "R" + digitsPattern(4) + ("a"|"b");

Match that pattern in a string:

str = "String arrays were introduced in R2016b. Patterns were added in R2020b.";
extract(str,pat)

ans =
2x1 string array
"R2016b"
"R2020b"

For more information, see pattern.

extract Function: Extract substrings from strings


To extract substrings from strings, use the extract function. You can specify the substring to be
extracted as literal text or by using a pattern object to match the text in a substring.

Functions: New validation functions for arguments and properties


The following functions are designed for use in function argument and property validation.

• mustBeA Validate that value comes from one of specified classes


• mustBeNonmissing Validate that value is not missing
• mustBeFloat Validate that value is floating-point array
• mustBeScalarOrEmpty Validate that value is scalar or empty
• mustBeVector Validate that value is vector
• mustBeInRange Validate that value is in the specified range
• mustBeFile Validate that path refers to file
• mustBeFolder Validate that input path refers to folder
• mustBeValidVariableName Validate that input name is valid variable name
• mustBeText Validate that value is a string array, character vector, or cell array of character
vectors
• mustBeTextScalar Validate that value is a single piece of text
• mustBeNonzeroLengthText Validate that value is string array, character vector, or cell array of
character vectors that has non-zero length

7-5
R2020b

underlyingType, isUnderlyingType, and mustBeUnderlyingType


Functions: Query the underlying data type of classes
The class function is useful to determine the class of a variable. However, some classes in MATLAB
can contain underlying data that has a different type compared to what class returns. Example
classes include gpuArray, dlarray, and distributed arrays. The underlyingType,
isUnderlyingType, and mustBeUnderlyingType functions now provide a simple way to query the
underlying data types of those classes.

For most classes, class(X) and underlyingType(X) return the same answer. However, for classes
that can contain underlying data of a different type, the return values are different. For a gpuArray X
that contains data of type double, for example, class(X) returns 'gpuArray', whereas
underlyingType(X) returns the underlying MATLAB data type, 'double'.

height and width Functions: Return number of rows or columns in an


array
The height and width functions now work with arrays in addition to tables. height returns the
number of rows in the array and width returns the number of columns.

Class conversions: Assignment operations convert more classes into


built-in data types
In assignment statements such as A(1:k) = C, where A has a built-in data type such as double,
MATLAB attempts to convert C to be the same data type as A using a series of conversions. That
conversion behavior has changed.

• Previously, only one conversion was attempted. This conversion attempted to use a class
conversion function, such as logical(C) or double(C), to obtain a variable with the same data
type as A.
• Now, if the first conversion fails, or if it returns a type that differs from A, then MATLAB attempts
a secondary conversion with cast(C,"like",A). If C belongs to a class that defines a cast
method that supports the "like" flag, and that method returns a value with the same type as A,
then MATLAB uses the resulting value to perform the assignment into A.

If both conversion attempts fail, then MATLAB throws a MATLAB:invalidConversion error.

An example of code that used to error, but now executes, is


a = 1:6;
g = distributed([11 12 13]);
a(1:3) = g

a =

11 12 13 4 5 6

Compatibility Considerations
Some assignment statements that used to throw an error now execute. If your code relied on the
errors that MATLAB threw for those conversions, such as within a try/catch block, then your code
might no longer catch those errors.

7-6
Language and Programming

Functionality being removed or changed


hex2dec, bin2dec, and base2dec Functions: Issue warning when inputs are greater than or
equal to flintmax
Behavior change

Starting in R2020b, the hex2dec, bin2dec, and base2dec functions issue a warning when their
inputs have values greater than or equal to flintmax. In previous releases, these functions did not
issue a warning when their inputs had such values.

These functions now issue a warning because inputs representing integers greater than or equal to
flintmax might not be represented exactly as double-precision floating-point values.

To convert values greater than flintmax exactly, consider one of these alternatives:

• In place of scalar text inputs, use hexadecimal or binary literals representing the same values.
When you write a value as a literal, MATLAB stores it as an integer that represents the value
exactly. For more information, see Hexadecimal and Binary Values.
• To convert hexadecimal inputs greater than flintmax, you can use the sscanf function with the
%lx operator. When you use %lx, the converted values are integers that have the uint64 data
type. These integers have enough storage to represent values greater than flintmax exactly.

Defining classes and packages: Using schema.m will not be supported in a future release
Still runs

Support for classes and packages defined using schema.m files will be removed in a future release.
Replace existing schema-based classes with classes defined using the classdef keyword.

7-7
R2020b

Data Analysis

Implicit Expansion: For calendarDuration, categorical, datetime, and


duration arrays, automatically expand dimensions of length 1 when
applying element-wise operations and functions
calendarDuration, categorical, datetime, and duration arrays now support implicit
expansion for certain operations and functions. In previous releases, these operations and functions
only supported implicit expansion for numeric and logical arrays.

Implicit expansion is a generalization of scalar expansion. With scalar expansion, a scalar expands to
be the same size as another array to facilitate element-wise operations. With implicit expansion, the
element-wise operators and functions listed in the table can implicitly expand their inputs to be the
same size, as long as the arrays have compatible sizes. Two arrays have compatible sizes if, for every
dimension, the dimension sizes of the inputs are either the same or one of them is 1. See Compatible
Array Sizes for Basic Operations and Array vs. Matrix Operations for more information.

For each operator or function, the table shows the data types that gained support for implicit
expansion in R2020b.

Operator or Function Data Types with New Support for Implicit


Expansion in R2020b
+ calendarDuration, datetime, and duration

-
.* calendarDuration, categorical, and
duration
./ duration

.\
.^ None
== categorical, datetime, and duration

~=
< categorical (ordinal arrays only), datetime,
and duration
<=

>

>=
max categorical (ordinal arrays only), datetime,
and duration
min
mod duration

rem
isbetween datetime and duration

7-8
Data Analysis

Compatibility Considerations
If your code uses any of the element-wise operators or functions listed above and relies on the errors
that MATLAB returns from mismatched sizes, particularly within a try/catch block, then your code
might no longer catch those errors. This change is because some combinations of input sizes that
previously caused errors are now valid.

For example, in older releases of MATLAB, you could not add a row and a column vector that are
duration vectors, but those operands are now valid for addition with implicit expansion. In other
words, an expression like seconds([1 2]) + seconds([1; 2]) previously returned a size
mismatch error, but now it executes.

normalize Function: Scale data by interquartile range


You can use the 'medianiqr' method with the normalize function to center data on a median of 0
and scale it to have an interquartile range of 1. Additionally, when using the 'scale' method, the
new 'iqr' option allows you to scale the data by the interquartile range.

groupsummary Function: Summarize data using functions that require


multiple input arguments
When specifying a summary computation, groupsummary now supports function handles and
anonymous functions that require more than one input argument.

fillmissing Function and Clean Missing Data Live Editor Task: Specify
maximum gap size to fill
When filling missing data using the fillmissing function, you can use the 'MaxGap' name-value
pair to fill only gaps of missing data up to a specified size. When using the Clean Missing Data Live
Editor task, enter a gap size next to Max gap to fill.

Clean Outlier Data Live Editor Task: Define outliers based on


percentile thresholds
The Clean Outlier Data Live Editor task now offers the option to define outliers in data as points
outside of a percentile range. To use this option, select Percentiles as the Detection method, and
specify values for the Lower threshold and Upper threshold.

Functionality being removed or changed


table and timetable Data Types: Change to dimension name selection when combining or
joining tables and timetables
Behavior change

In R2020b, when you combine tables and timetables, the dimension names of the output table come
from the first nondefault dimension names in the input table and timetables. In previous releases, the
dimension names always came from the first input, even when that table or timetable had default
dimension names.

7-9
R2020b

For example, if TT1 and TT2 are timetables, and TT2 has the nondefault name 'Start' as the name
of its first dimension, then when you concatenate the timetables the output also has 'Start' as the
name of its first dimension. The name of the first dimension of TT1 is 'Time', but that is a default
dimension name. In previous releases, the name of the first dimension of the output was 'Time'
because that name was in the first input timetable.

TT1 = timetable(seconds(1:2)',[1;2]);
TT2 = timetable(seconds(1:2)',[3;4]);
TT2.Properties.DimensionNames{1} = 'Start';
TT = [TT1 ; TT2]

TT =

4×1 timetable

Start Var1
_____ ____

1 sec 1
2 sec 2
1 sec 3
2 sec 4

This change in behavior affects the functions in this list.

• cat
• horzcat
• innerjoin
• outerjoin
• setxor
• union
• vertcat

Retime Timetable Live Editor Task: Use linear interpolation as default general rule for
adjusting data
Behavior change

In R2020b, linear interpolation is the default general rule for adjusting data in the Retime
Timetable live editor task. In previous releases, the default general rule is to fill gaps in the output
timetable with missing values.

However, even in R2020b the default rule reverts to filling gaps with missing values if either of these
conditions is met:

• The row times of the input timetable are not sorted.


• The input timetable has at least one variable whose data type is not numeric, datetime, or
duration.

7-10
Data Import and Export

Data Import and Export

readstruct and writestruct functions: Read and write structured data


in XML files
Read and write structured data stored in XML files using the readstruct and writestruct
functions:

• Use the readstruct function to read structured data stored as XML files.
• Use the writestruct function to write MATLAB structures to XML files.

readlines function: Read the lines in a text file as a string array


Use the readlines function to read each line in a text file as an N-by-1 string array, where N is the
number of lines in the text file. For more information, see readlines.

Spreadsheet files: Customize formatting when writing data to


spreadsheet files with PreserveFormat and AutoFitWidth
The writecell, writetable, writematrix, and writetimetable functions have two new name-
value pairs that enable you to format spreadsheet files: 'PreserveFormat' and 'AutoFitWidth'.

• 'PreserveFormat' specifies whether to preserve the existing cell formatting of the original
data.
• 'AutoFitWidth' specifies whether to automatically adjust the column width of the spreadsheet
file to fit the data.

imread function and Tiff object: Read images from Aperio SVS and
TIFF files containing JPEG2000 compression
The imread function and the Tiff object can now read Aperio SVS microscopy image files and TIFF
image files with JPEG2000 compression.

ArrayDatastore object: Create datastores from in-memory data


The arrayDatastore function creates a datastore from in-memory data. You can combine
ArrayDatastore objects with datastores that contain on-disk data (such as ImageDatastore and
TabularTextDatastore objects) using the combine and transform functions. To choose the ways
that an ArrayDatastore object reads and returns data, specify these properties:
'IterationDimension', 'ReadSize', and 'OutputType'. For more information, see
arrayDatastore.

Datastore: Transform multiple datastores using the transform


function
The transform function now accepts multiple datastores as input. Specify each datastore as another
input argument.

7-11
R2020b

ds = transform(@fcn, ds1, ds2, ds3);

The transform function creates one TransformedDatastore object from the resulting
transformation. For more information on the TransformedDatastore object, see
TransformedDatastore.

FileDatastore object: Shuffle and create subsets of a FileDatastore


You can use the shuffle and subset functions to shuffle and create subsets of a FileDatastore
object. You must use the 'ReadMode','file' name-value pair argument to use subset and
shuffle on a FileDatastore object.

writeall function: Write data from text and spreadsheet files to


different row groups in Parquet files
In R2020b, when writing to parquet files using the writeall function, you do not need to set the
ReadSize property of TabularTextDatastore, SpreadsheetDatastore, or ParquetDatastore
objects to 'file'. writeall will write the amount of data specified by the ReadSize property of
the datastore to a separate row group in the Parquet file.

fileparts function: Parse file names specified as cell arrays of


character vectors and string arrays
The fileparts function now accepts cell arrays of character vectors and string arrays as the input
file names.

Audio devices: Refresh the available audio devices using the


audiodevreset function
You can use the audiodevreset function to refresh the available audio devices after adding or
removing a device from your machine. Use the audiodevinfo function to view the updated list of
audio devices.

Audio files and web-based data: Read and write remotely stored audio
files using audioread, audiowrite, and audioinfo
You can access audio files stored in remote locations, such as Amazon S3, Windows Azure Blob
Service, and HDFS™, using the audioread, audiowrite, and audioinfo functions.

When reading data from a remote location, you must specify the full path using a uniform resource
locator (URL). For example, read a .wav file from the Amazon S3 cloud.

audio = audioread('s3://bucketname/path_to_file/sample_audio.wav');

For more information on setting up MATLAB to access your online storage service, see Work with
Remote Data.

7-12
Data Import and Export

HDF5 files and web-based data: Read and write remotely-stored HDF5
files using existing HDF5 functions
MATLAB HDF5 functions can now work with remote files. Use the existing high-level and low-level
functions to read and write files stored in remote locations, such as Amazon S3, Windows Azure Blob
Service, and HDFS.

When reading data from a remote location, you must specify the full path using a uniform resource
locator (URL). For example, display the metadata of an HDF5 file from the Amazon S3 cloud.

h5disp('s3://bucketname/path_to_file/my_file.h5');

For more information on setting up MATLAB to access your online storage service, see Work with
Remote Data.

HDF5 files: Read and write file names encoded using Unicode
characters
You can now read and write file names encoded as Unicode characters using the high-level and low-
level HDF5 functions in MATLAB.

Scientific File Format Libraries: NetCDF library upgraded to 4.7.3


The NetCDF library is upgraded to version 4.7.3.

Image File Format Libraries: LibTIFF library upgraded to version 4.1.0


The LibTIFF library is upgraded to version 4.1.0.

Bluetooth Interface: Support for communicating with Bluetooth


devices
You can now use MATLAB to connect to Bluetooth devices and transmit and receive ASCII and binary
data.

Get started with the new interface by viewing a list of all Bluetooth devices on your computer using
bluetoothlist. In this example, an HC-06 Bluetooth module is paired to the computer.

list = bluetoothlist
list=1×4 table
Name Address Channel Status
_____________ ______________ _______ __________________

"HC-06" "98D331FB3B77" 1 "Ready to connect"

Then, create a bluetooth object, write data to the device, and read from it. In this example, the
HC-06 is configured as a loopback device.

b = bluetooth("HC-06");
write(b,1:10);
read(b,10);

For more information, see Bluetooth Communication.

7-13
R2020b

TCP/IP Client Interface: New functions and properties


The TCP/IP client interface has a new set of functions and properties.

You can still perform the following operations using existing functions:

• Create a TCP/IP client connection with a TCP/IP server using the tcpclient function.
• Read data from a remote host using the read function.
• Write data to a remote host using the write function.

You can now perform the following operations using new functions:

• Start an echo TCP/IP server using the echotcpip function.


• Read a line of ASCII string data from a remote host using the readline function.
• Write a line of ASCII string data to a remote host using the writeline function.
• Set a terminator for ASCII string communication with a remote host using the
configureTerminator function.
• Set a callback function and trigger condition for communication with a remote host using the
configureCallback function.
• Flush buffers for communication with a remote host using the flush function.

Get started with the TCP/IP client interface by creating a tcpclient object connected to a TCP/IP
echo server, writing data to it, and reading from it.

echotcpip("on",3030)
t = tcpclient("localhost",3030)
write(t,1:5,"uint8")
read(t,5);

For more information, see TCP/IP Communication.

Serial Port Interface: Improved performance


The serialport interface shows improved performance over the serial interface. For example,
this code for writing and reading data with the serialport object is about 1.1x faster than the code
for writing and reading data with the serial object with the default baud rate of 9600.

% s is a serial object
function timingTest(s,bytecount)
fwrite(s,1:bytecount,"uint8");
fread(s,bytecount,"uint8");
end

% s is a serialport object
function timingTest(s,bytecount)
write(s,1:bytecount,"uint8");
read(s,bytecount,"uint8");
end

The approximate execution times for different baud rates follow:

s.BaudRate

7-14
Data Import and Export

9600 19200 56000 115200


serial 120 ms 68 ms 31 ms 23 ms
serialport 109 ms 55 ms 21 ms 11 ms

The code was timed on a Windows 10, Intel(R) Xeon(R) CPU E5-1650 v4 @ 3.60 GHz test system
using the timeit function:

bytecount = 100;
timeit(@()timingTest(s,bytecount))

The tests were done using a serial loopback connector.

For more information, see Serial Port Devices.

Functionality being removed or changed


The 'PreserveVariableNames' property of readtable is no longer recommended
Behavior change

The 'PreserveVariableNames' property of readtable has been removed. Use the


'VariableNamingRule' name-value pair instead. Specify one of the following values:

• 'preserve' preserves variable names that are not valid MATLAB identifiers, such as variable
names that include spaces and non-ASCII characters.
• 'modify' converts invalid variable names to valid MATLAB identifiers.

The UnderlyingDatastore property of TransformedDatastore is no longer recommended


Behavior change

The UnderlyingDatastore property of TransformedDatastore has been removed. Use the


UnderlyingDatastores property instead. Calling the UnderlyingDatastores property returns a
cell array containing zero or more datastores. For more information, see TransformedDatastore.

The partition function adds remaining observations to the first existing partitions
Behavior change

If you specify a number of partitions in the partition function that is not a numerical factor of the
number of files in the datastore, the partition function will place each of the remaining
observations in the existing partitions, starting with the first partition.

The number of existing partitions that contain an additional observation is equal to the remainder
obtained when dividing the number of files in the datastore by the number of partitions. For example,
if your datastore object contains 23 files that you wish to partition into 3 parts, the first two partitions
that partition creates will contain 8 files, and the last partition will contain 7 files.

Server certificate and hostname validation are enabled by default when accessing
OPeNDAP servers with the NetCDF interface
Behavior change

In R2020b, the MATLAB NetCDF interface connects only to trusted data access protocol (DAP)
endpoints by default. Previously, when you accessed an OPeNDAP server, both the server certificate
and hostname validation were disabled by default.

7-15
R2020b

To learn how to disable server certificate and hostname validation when accessing an OPeNDAP
server, see Import NetCDF Files and OPeNDAP Data.

isSingleReadPerFile has been removed

The isSingleReadPerFile function of the matlab.io.datastore.FileWritable class has


been removed.

7-16
Mathematics

Mathematics

Optimize Live Editor Task: Solve optimization problems interactively


The Optimize Live Editor task lets you optimize multivariable functions or solve scalar equations
interactively. The task provides a visual way to access the fminbnd, fminsearch, fzero, and
lsqnonneg solvers and set their options. For an example, see Optimize Live Editor Task.

pagemtimes Function: Perform matrix multiplication on pages of N-D


arrays
Use the pagemtimes function to perform batched matrix multiplication on the pages of N-D arrays.
In this context, the N-D array is treated as a container for several 2-D matrices.

pagetranspose and pagectranspose Functions: Transpose pages of N-


D arrays
Use the pagetranspose and pagectranspose functions to transpose the pages of an N-D array. In
this context, the N-D array is treated as a container for several 2-D matrices.

svdsketch Function: Compute SVD factors of low-rank matrix sketch


svdsketch computes the singular value decomposition (SVD) factors of a low-rank sketch of the
input matrix. This operation preserves the most important features of the matrix based on a specified
tolerance. For large matrices, svdsketch can typically compute an approximate SVD faster than
svds.

Functionality being removed or changed


'cubic' method of interp1 performs cubic convolution
Behavior change

In R2020b, the 'cubic' interpolation method of interp1 performs cubic convolution. The
'v5cubic' and 'cubic' interpolation methods now perform the same type of interpolation, which is
consistent with the behavior of interp2, interp3, and interpn. The cubic convolution
interpolation method is intended for uniformly-spaced data, and it falls back to 'spline'
interpolation for irregularly-spaced data.

In previous releases, 'cubic' was the same as 'pchip', and only 'v5cubic' performed cubic
convolution.

7-17
R2020b

Graphics

bubblechart, bubblechart3, and polarbubblechart Functions: Create


bubble charts in 2-D, 3-D, and in polar coordinates
Use the bubblechart and bubblechart3 functions to create bubble charts in 2-D and 3-D
Cartesian spaces, respectively. Use the polarbubblechart function to create bubble charts in polar
coordinates.

Use the following functions to customize different aspects of your bubble charts:

• bubblelegend function — Illustrate the correspondence between the bubble sizes and the data
values.
• bubblelim function — Control the correspondence between the relative bubble sizes and the
data values.
• bubblesize — Control the absolute bubble sizes in points, where one point equals 1/72 inch.

Swarm charts and Scatter objects: Visualize distributions of discrete


data
Use the swarmchart function to visualize distributions of scattered points at discrete values of X.
Use the swarmchart3 function to visualize distributions for combinations of discrete X and Y. Both
functions return Scatter objects that have these new properties:

• XJitter, YJitter, and ZJitter — Control the algorithm for spreading (jittering) the points
along the x-, y-, or z-dimensions.
• XJitterWidth, YJitterWidth, and ZJitterWidth— Control the maximum amount of jitter.

7-18
Graphics

scatter Function: Vary the transparency across all points


When you create a scatter plot using the scatter function, you can vary the level of transparency
across the points by setting the AlphaData and AlphaDataMapping properties of the Scatter
object.

tiledlayout and nexttile Functions: Improved placement of legends,


and colorbars, and shared decorations
Improved Legend and Colorbar Placement

• You can now place shared legends, shared colorbars, or additional axes into any of four outer tiles
around the perimeter of a tiled chart layout. For more information, see nexttile.

7-19
R2020b

• Tiled chart layouts also provide more support for positioning legends. When you add a legend to a
plot, the layout provides better support for the 'best', 'bestoutside', and 'none' location
options.

More Consistent Layout for Shared Decorations and Polar Axes

• When you include shared decorations (such as shared titles and colorbars) and manually adjust
the axes aspect ratios, the presentation is better and more consistent with other layouts.
• The presentation is also better for layouts containing polar axes with the 'flow' tile
arrangement.

axis Function: Pad axis limits to show plotted data near the limits
more clearly
Specify the 'padded' option when calling the axis function to pad the upper and lower limits of the
x- and y-axis. This option is helpful when your plot displays data near one or more of the axis limits.

7-20
Graphics

Titles, Subtitles, and Axis Labels: Add subtitles to plots, and align
titles and axis labels with the plot box
Create Subtitles

• Create a title and subtitle for a plot by calling the title function with two character vector or
string arguments.
• For more control over the appearance of each text object, call the title and subtitle functions
separately.

7-21
R2020b

Align Titles and Axis Labels to the Plot Box

• Align a title by setting the TitleHorizontalAlignment property of the axes to 'left',


'right', or 'center'.
• Align an axis label by setting the LabelHorizontalAlignment property of the ruler object to
'left', 'right', or 'center'. Use the XAxis, YAxis, or ZAxis property on the axes object to
access the ruler object.

For example, this code creates a plot with a left-aligned title and axis labels.
plot([0 3 1 6])
title('Experimental Results')
xlabel('Input Values')
ylabel('Measured Values')
ax = gca;
ax.TitleHorizontalAlignment = 'left';
ax.XAxis.LabelHorizontalAlignment = 'left';
ax.YAxis.LabelHorizontalAlignment = 'left';

Data Tips: Customize data tip content on standalone visualizations


Add or remove rows from data tips on standalone visualizations that you create from tables. You can
customize data tips for these standalone visualizations:

• Heatmap charts created using the heatmap function


• Scatter plots with marginal histograms created using the scatterhistogram function
• Geographic bubble charts created using the geobubble function
• Parallel coordinates plots created using the parallelplot function

To add or remove rows, right-click on the chart and hover over Modify Data Tips. Then, select or
deselect table variables.

7-22
Graphics

turbo Colormap: jet colormap alternative with more perceptually


uniform transitions
Use the turbo colormap to display visualizations using a colormap that is similar to jet, but with
more perceptually uniform transitions along the color scale. Perceptually uniform colormaps help you
to visualize the differences in your data more accurately.

These colorbars show the difference between the turbo and jet colormaps. The turbo colormap is
on top, and the jet colormap is on the bottom.

Colormap Editor: Customize colormaps using modernized interface


Customize colormaps using the modernized interface of the Colormap Editor. Starting in R2020b, you
can use the Colormap Editor to:

• Import a colormap as an m-by-3 array from the workspace.


• Save a customized colormap as a workspace variable.
• Shift the placement of colors in the colormap.
• Reverse the order of colors in the colormap.
• Change the number of elements in the colormap.

7-23
R2020b

boxchart Function: Use color to differentiate between box charts


Use color to differentiate between box charts by specifying the 'GroupByColor',cgroupdata
name-value pair argument of boxchart. The function creates a box chart for each group of data and
assigns the same color to groups with the same cgroupdata value. You can specify the color
grouping variable with or without a positional grouping variable. For an example, see Use Positional
and Color Grouping Variables.

im2gray and cmap2gray: Convert images and colormaps to grayscale


Use the im2gray function to convert colored images to grayscale. Use the cmap2gray function to
convert a colormap to grayscale.

validatecolor Function: Calculate normalized RGB triplets for color


names, hexadecimal color codes, or integer values
Use the validatecolor function to calculate the normalized RGB triplet values for colors specified
in any of the following ways:

• Color names, such as 'red' or 'green'


• Hexadecimal color codes, such as '#FF0000' or '#F00'
• Integer RGB triplets, such as uint8([255 0 0])

7-24
Graphics

Markers: Specify horizontal or vertical line markers for plots


Create plots with horizontal or vertical line markers when you call plotting functions such as plot or
scatter. Specify horizontal line markers using the underscore ('_') symbol. Specify vertical line
markers using the pipe ('|') symbol.

surfc and meshc Functions: Specify Z-level for contours on surface


and mesh plots
When you create a surface or a mesh plot with contour lines using the surfc or meshc functions, you
can display the contours at any z-level by specifying the ZLocation property of the Contour object.
The ZLocation property can have a value of 'ZMin', 'ZMax', or a numeric value. The default value
is 'ZMin', which corresponds to the lowest level shown in the plot box.

7-25
R2020b

animatedline Function: Create animated lines in polar plots


Create animated polar plots by calling the animatedline function and specifying a PolarAxes
object as the first input argument.

colororder Function: Control colors in geographic bubble charts


The colororder function now supports charts created with the geobubble function.

Functionality being removed or changed


Calling the alpha function with the alphadata, facealpha, or alphadatamapping arguments
changes Scatter objects in the axes
Behavior change

Scatter objects in the axes are affected when you call the alpha function with the alphadata,
facealpha, or alphadatamapping arguments without specifying a particular object within the axes
to modify.

In R2020a and earlier releases, the alphadata, facealpha, and alphadatamapping arguments
have no effect on Scatter objects in the axes.

For example, this code creates a surface plot and a scatter plot, and then calls the alpha function to
vary the transparency along the x-dimension. In R2020a, only the surface plot changes when you call
the alpha function. In R2020b, both plots are affected.

[X,Y] = meshgrid(-10:10);
Z = ones(21,21) * -2;
surf(X,Y,Z)
hold on
scatter([-8 2 4 -5 5 3],[7 4 2 -1 -7 0],200,'filled')
alpha('x')

7-26
Graphics

To prevent Scatter objects from changing, specify the object to modify as the first argument to the
alpha function. For example, to update the preceding code, call the surf function with an output
argument s. Then pass s to the alpha function to modify only the Surface object.

[X,Y] = meshgrid(-10:10);
Z = ones(21,21) * -2;
s = surf(X,Y,Z)
hold on
scatter([-8 2 4 -5 5 3],[7 4 2 -1 -7 0],200,'filled')
alpha(s,'x')

Colormap 'default' option for heatmap displays the blue colormap instead of parula
Behavior change

Setting the colormap on a heatmap chart to 'default' sets the chart's colormap to the default blue
colormap for heatmap charts. In R2020a and previous releases, the 'default' option changes the
colormap to parula.

To specify the default colormap for a heatmap chart, pass the chart to the colormap function.

h = heatmap(rand(10));
colormap(h,'default')

Only heatmap charts are affected by this change.

rbbox and dragrect do not display rectangles outside of the figure window
Behavior change

If you begin dragging a rectangle using the rbbox or dragrect functions and then move part of it
past the edge of the figure window, only the part of the rectangle that is inside the window is visible.
In R2020a and earlier releases, the whole rectangle is visible, even the part that is outside of the
figure window.

This change does not affect the values returned by rbbox or dragrect.

This code and table compares the behavior of rbbox in R2020a and R2020b.

waitforbuttonpress
[finalRect] = rbbox

7-27
R2020b

R2020a R2020b

finalRect = finalRect =

332 290 311 126 332 290 311 126

Data tips on charts created from tables display the first dimension name and row names
Behavior change

When you create a chart from a table, the data tips include the row information you provide. For
instance, if you change the first dimension name of the table, then the data tips display that name
instead of Row. In addition, if you specify row names for the table, then the data tips display the row
names instead of the row numbers.

By default, the first dimension name of table arrays is 'Row' and the row names are empty. This
means the behavior in R2020b only differs from earlier releases when you change the
DimensionNames or RowNames properties of the table array.

For example, load the patients data set and create a table. Change the dimension names from
{'Row','Variables'} to {'Patient','Data'} and the row names from {} to LastName. Then,
create a scatter plot with marginal histograms. The image shows the differences in the data tips for
R2020a and R2020b.

load patients
tbl = table(LastName,Age,Gender,Height,Weight);
tbl.Properties.DimensionNames = {'Patient','Data'};
tbl.Properties.RowNames = LastName;
scatterhistogram(tbl,'Height','Weight')

7-28
Graphics

The charts affected by this change are:

• Heatmap charts created using the heatmap function


• Scatter histogram charts created using the scatterhistogram function
• Geographic bubble charts created using the geobubble function
• Parallel coordinates plots created using the parallelplot function

7-29
R2020b

App Building

uitable Function: Configure column widths to use weighted variable or


to automatically adjust to fit data
Configure the column widths of table UI components. You can use a weighted variable width or you
can automatically adjust the width to fit the data and column names.

To specify a weighted variable width, set the ColumnWidth property value to a number paired with
an 'x' character (for example, '2x'). To configure columns to automatically adjust to column names
and data, set the ColumnWidth property value to 'fit'.

The 'fit' and 'Nx' ColumnWidth property values are supported only in App Designer and
uifigure-based apps.

For more information, see Table Properties.

scroll Function: Scroll to the top or bottom of a text area


programmatically
Use the scroll function to scroll to the top or bottom of a text area component programmatically.

WindowStyle Property: Create modal UI figures


To restrict keyboard and mouse interactions to a specific UI figure window, set the WindowStyle
property to 'modal'. For more information see, UI Figure Properties.

Icon Property: Specify custom icons for UI figure windows and toolbar
push and toggle tools
You can now add custom icons to figures created with the uifigure function. You can also specify
custom icons as image files for toolbar push and toggle tools in App Designer or uifigure-based
apps. To specify a custom icon, set the Icon property value to an image file or an m-by-n-by-3
truecolor array.

For push and toggle tools created in App Designer and uifigure-based apps, use the Icon property
to specify icons instead of the CData property.

For more information, see UI Figure Properties, PushTool Properties or ToggleTool


Properties.

WordWrap Property: Wrap long text to fit the width of certain UI


components
Use the WordWrap property to prevent text from getting clipped horizontally when the width of your
UI component is smaller than the text you want to display. Label, CheckBox, RadioButton,
Button, StateButton, ToggleButton, and TextArea objects support the WordWrap property.

7-30
App Building

Setting the WordWrap property value to 'on' breaks the text into new lines so that each line fits
within the component. It avoids breaking words when possible. When the value is set to 'off' the
text does not wrap.

For more information, see Label Properties.

Enable Property: Turn interaction off and on for buttons and panel
groups
To control whether a panel or button group responds to user interaction, use the Enable property.

For example, when the Enable property of a panel is set to 'on' you can interact with it, and with UI
components within it as long as they are enabled. When the Enable property is set to 'off', you
cannot interact with the panel or its content. Changing the value of the Enable property for a panel
does not change the value of the Enable property for UI components contained within it. The
Enable property for button groups behaves in the same way.

The Enable property is supported only for panels and button groups in App Designer and uifigure-
based apps.

For more information, see Panel Properties.

BackgroundColor Property: Set the background color for grid layouts


Set the BackgroundColor property on GridLayout objects (created with the uigridlayout
function). The default background color is the same as the default color for all parent containers,
such as figures and panels.

Custom Components: Develop your own class of UI components


Define your own class of UI components by creating a subclass of the
matlab.ui.componentcontainer.ComponentContainer base class. Create a class to make
composite UI components that use multiple MATLAB UI components or graphics objects.

Creating a class has these benefits:

• A convenient interface — When users want to customize an aspect of your UI component, they can
set a property rather than having to modify and rerun your code. Users can modify properties at
the command line or inspect them in the Property Inspector.
• Encapsulation — Organizing your code in this way allows you to hide implementation details from
your users. You implement methods that perform calculations and manage the underlying graphics
objects.

For more information, see UI Component Development Overview.

App Designer: Allow only one running instance of your app at a time
In App Designer, you can select whether your app can run multiple instances at a time or only a
single instance.

To change the run behavior of your app, select the App node from the Component Browser. Then,
from the Code Options section of the Inspector tab, select or clear Single Running Instance.

7-31
R2020b

When Single Running Instance is selected and you run the app multiple times, MATLAB reuses the
existing instance and brings it to the front rather than creating a new one. When Single Running
Instance is not selected, then a new app instance is created each time you run it, while existing
instances of the app also continue to run.

Selecting or clearing Single Running Instance does not change the App Designer run behavior of
the app. Regardless of the Single Running Instance option, App Designer always closes the
existing app instance before creating a new one.

For more information, see Manage Code in App Designer Code View.

App Designer: Change the stacking order of UI components


To change the stacking order (also known as z-order) of components in your app, select a component.
Then, in the App Designer toolstrip, expand the Reorder drop-down menu from the Arrange
section of the Canvas tab and select a reorder option. Alternatively, right-click a component and
select an option from the Reorder menu.

App Designer: Add and configure toolbar components on the App


Designer canvas
Add a toolbar component to your app by dragging one from the Component Library onto the canvas.
Configure the toolbar by adding push or toggle tools to it. Then, add icons to the tools and configure
their callbacks.

App Designer: Draw UI components on the App Designer canvas


In App Designer, you can now draw UI components from the Component Library on the canvas.

To draw a component on the canvas, select it from the Component Library and then move your
cursor over the canvas. The cursor changes to a crosshair. Click your mouse to add the component to
the canvas in its default size, or click and drag to size the component as you add it.

App Designer: Find differences and merge apps


You can use the Comparison Tool to find differences between apps. The Comparison Tool highlights
differences in the code of two apps. To start a comparison of two apps, go to the Home tab, and in
the File section, click Compare, and then select the files that you want to compare. To start a
comparison from the Current Folder browser, select a file, right-click, and select Compare Against.

You also can merge changes in callback and utility functions from one file to the other. Merging
changes can be useful when resolving conflicts between different versions of an app. To merge two
apps, in the Comparison Tool, select the Merge Mode button to start the merge. Use the
button to replace content in the right pane with content from the left pane. The right pane contains

the merged result. To save the result, click the Save Result button.

For more information, see Compare and Merge Apps.

7-32
App Building

Graphics Support: Create more plots in apps with full support for any
type of axes
All plotting workflows are now supported in App Designer apps and in apps you create
programmatically with the uifigure function. For example:

• You can add more types of plots to an app, including pareto, plotmatrix, and boxplot.
• You can place any type of axes or standalone visualization (such as a heatmap) directly into a
scrollable container or in a GridLayout.
• You can place a tiled chart layout directly into a scrollable container or in a GridLayout.

Also, UIAxes objects now have the same properties and options as Axes objects have for customizing
their appearance and behavior:

• You can use the InnerPosition property to align UI components with the plot box.
• You can use the PositionConstraint property to control the space around the plot box when
you add or modify decorations such as titles and axis labels.
• The Units property of a UIAxes object now supports all units: 'pixels', 'normalized',
'inches', 'centimeters', 'points', and 'characters'. The default value is 'pixels'.
• You can use the ButtonDownFcn, PickableParts, and HitTest properties to make the UIAxes
object capture and respond to mouse clicks.

Graphics Support: Identify coordinates and display text by clicking or


tapping
You can now identify coordinates or display text at specified locations by clicking or tapping within
App Designer figures or figures created with the uifigure function. To identify axes coordinates,
call the ginput function. Then, select the locations to identify by clicking or tapping. To display text,
call the gtext function and specify the text as an argument. Then, select the locations for the text by
clicking or tapping. For more information about using the ginput and gtext functions within App
Designer, see Display Graphics in App Designer.

Additionally, you can now migrate GUIDE apps that use ginput or gtext. For more information, see
GUIDE Migration Strategies.

App Capture: Capture user interfaces using exportapp and getframe


Capture the all the graphical content in an app, including UI components, as an image file, a PDF file,
or an image array in your MATLAB workspace.

• Call the exportapp function to capture the content as a JPEG, PNG, or TIFF file, or as a PDF file
containing vector graphics.
• Call the getframe function with a return argument to capture the content as an image array in
your workspace. To ensure all the UI components are included, specify the figure as the first input
argument of the getframe function. The figure can be one created with the uifigure function,
or it can be the figure in an App Designer app. By default, App Designer stores the figure in the
UIFigure property of the app.

7-33
R2020b

App Testing Framework: Perform choose gestures on context menu


items
The chooseContextMenu method enables you to test choose gestures on context menu items for UI
components. For example, create a context menu with two menu items in a UI figure and choose one
of the menu items.
fig = uifigure;
cm = uicontextmenu(fig);
m1 = uimenu(cm,'Text','Menu1');
m2 = uimenu(cm,'Text','Menu2');
fig.ContextMenu = cm;

tc = matlab.uitest.TestCase.forInteractiveUse;
tc.chooseContextMenu(fig,m1)

App Testing Framework: Perform drag gestures on axes and UI axes


The app testing framework supports drag gestures on axes and UI axes. When you test a drag
gesture on an axes or UI axes, the framework mimics a user manipulating the component and adjusts
the axes limits based on the difference between the start and stop values. For example, create an
axes with a plot and then drag from the point (3, 2) to the point (4, 2).
f = uifigure;
ax = axes(f);
plot(ax,1:10)

tc = matlab.uitest.TestCase.forInteractiveUse;
tc.drag(ax,[3 2],[4 2])

App Testing Framework: Perform gestures on push tools and toggle


tools
The app testing framework supports gestures on more UI components.

• Perform press gestures in tests on push tools.


• Perform press and choose gestures in tests on toggle tools.

Functionality Being Removed or Changed


App Designer StartupFcn is now a callback of the app instead of the figure
Behavior change

The StartupFcn callback is now a callback of the app instead of the UI figure. Also, the app is now
the root node in the App Designer Component Browser hierarchy. The name of the app node is the
same as the name of your MLAPP file.

When you load apps created with MATLAB R2020a or earlier into R2020b, the app node is
automatically added to the hierarchy. To access the StartupFcn callback, select the app node from
the Component Browser. Then, select the callback from the Callbacks tab. The code in your
startupFcn callback function is not changed.

7-34
App Building

App Designer Component Browser hierarchy now uses the z-order of components
Behavior change

The App Designer Component Browser hierarchy now lists components according to their stacking
order (z-order) instead of their creation order.

GridLayout background is no longer transparent


Behavior change

GridLayout objects now have a BackgroundColor property and they are no longer transparent.
The default background color is the default color for all containers (for example, figures and panels).

If your app has a grid layout in a container that has a nondefault color, then set the
BackgroundColor property of the GridLayout object to that color to preserve the appearance of
your app.

If your app has objects behind the grid that you want to remain visible, move those objects into the
grid by making them children of the GridLayout object.

BackgroundColor property of UIAxes has no effect


Behavior change

Setting the BackgroundColor property on a UIAxes object no longer has any effect. The area
around the plot box is transparent regardless of the value of the BackgroundColor property.

To produce the same effect as setting the background color in previous releases, create a panel with
the desired BackgroundColor value, and then place the UIAxes in the panel.

UIAxes appear behind all other objects in the figure


Behavior change

The stacking order (also called the z-order) of objects in the figure has changed so that UIAxes
objects and their contents appear behind other UI components in the figure. This behavior is
consistent with the behavior of other types of axes.

For example, this code creates a figure, a button, and then a UIAxes object.

fig = uifigure;
b = uibutton(fig);
uax = uiaxes(fig);

In R2020a, executing the preceding code displays the UIAxes in front of the button, as shown in the
figure on the left. The figure on the right shows the behavior in R2020b, where the UIAxes appears
behind UI components regardless of the order of creation.

7-35
R2020b

The order of the objects listed in the Children property of the figure also reflects this change. The
UIAxes object is always after UI components in the list.

fig.Children

ans =

2×1 graphics array:

Button (Button)
UIAxes

Plots in UIAxes might extend outside the bounds of the axes


Behavior change

Plot objects such as lines might not clip to the bounds defined by the OuterPosition property of the
UIAxes. A line extends beyond the bounds when its Clipping property is set to 'off'. In previous
releases, lines clip to the OuterPosition regardless of the value of the Clipping property. For
example, the plot on the left shows the R2020a behavior, and the plot on the right shows the R2020b
behavior. In both cases, the Clipping properties of the lines are set to 'off'.

7-36
App Building

To prevent the axes content from overlapping with components in your app, set the Clipping
property of each object in the axes to 'on'.

Colorbars and legends displayed with UIAxes have the same parent as UIAxes
Behavior change

When you create a plot in a UIAxes object, and then create a colorbar or legend for that plot, the
parent object of the colorbar or legend is the same as the parent object of the UIAxes object. In
previous releases, the parent object of the colorbar or legend is the UIAxes object.

UIAxes SizeChangedFcn callback has been removed


Errors

The SizeChangedFcn callback for UIAxes objects has been removed. If your app requires a callback
that executes when the size of the axes changes, create a SizeChangedFcn callback for the parent
figure or another container.

7-37
R2020b

Performance

sum Function: Improved performance summing the first dimension of


numeric arrays
The performance of the sum function has improved when operating on the first dimension of numeric
inputs:

• sum(A,1) and sum(A,'all') are faster for matrix or N-D array A.


• sum(v) is faster for row or column vector v.

This performance improvement was added for single inputs in R2017b, and it has now been added
for all other numeric types in R2020b: double, logical, and integer data types (int8, int16, …).

For example, if you sum the elements of a vector with 1e9 elements in a loop, performance in R2020b
is about 1.4x faster than in R2020a.

function timingSum
x = 1/100;
v = x*ones(1e9,1);

tic
for i = 1:10
b = sum(v);
end
toc
end

The approximate execution times are:

R2020a: 2.0 s

R2020b: 1.4 s

The code was timed on a Windows 10, Intel Xeon W-2133 CPU @ 3.60 GHz test system by calling the
function timingSum.

Compatibility Considerations
This performance improvement arises from code changes that also lead to a different set of round-off
behaviors in sum. The new algorithm reduces the amount of round-off error in calculations, which
leads to a more accurate result in general. Therefore, the output of sum might change slightly in
R2020b compared to R2020a when operating on numeric inputs, even though the results between the
two versions are numerically equivalent.

polyfit Function: Improved performance fitting data


The performance of the polyfit function has improved for input data of all sizes and fits of any
order.

For example, if you fit a quadratic polynomial to a 500-element vector in a loop, performance in
R2020b is about 25x faster than in R2020a.

7-38
Performance

function timingPolyfit
rng default
x = 1:500;
y = -0.3*x + 2*randn(1,500);

for i = 1:1e4
p = polyfit(x,y,2);
end
end

The approximate execution times are:

R2020a: 3.5 s

R2020b: 0.14 s

The code was timed on a Windows 10, Intel Xeon W-2133 CPU @ 3.60 GHz test system using the
timeit function:

timeit(@timingPolyfit)

Compatibility Considerations
The performance improvement arises from changes to the polyfit algorithm that also produce more
accurate results. Therefore, the output of polyfit might change slightly in R2020b compared to
R2020a, even though the results between the two versions are numerically equivalent.

accumarray Function: Improved performance with fill values and


certain function handles
The performance of the accumarray function has improved in these cases:

• When you use the default @sum accumulation function and specify the fillval input.
• When you specify the accumulation function as @min or @max.

For example, when you accumulate a vector with 10,000 elements into an output vector with 100
elements and specify a fill value, performance in R2020b is about 14x faster than in R2020a.

function timingAccumarrayFillVal
rng default
subs = randi(1e2,1e4,1);
val = randn(1e4,1);
sz = [1e2 1];
fillval = 1;

for k = 1:2e4
A = accumarray(subs,val,sz,[],fillval);
end
end

The approximate execution times are:

R2020a: 11.2 s

R2020b: 0.8 s

7-39
R2020b

Also, when you accumulate a vector with 10,000 elements into an output vector with 100 elements
and specify the accumulation function as @min or @max, performance in R2020b is about 8.4x faster
than in R2020a.

function timingAccumarrayFcnHandle
rng default
subs = randi(1e2,1e4,1);
val = randn(1e4,1);
sz = [1e2 1];

for k = 1:2e4
A = accumarray(subs,val,sz,@max);
end
end

The approximate execution times are:

R2020a: 7.6 s

R2020b: 0.9 s

In each case, the code was timed on a Windows 10, Intel Xeon W-2133 CPU @ 3.60 GHz test system
using the timeit function:

timeit(@timingAccumarrayFillVal)
timeit(@timingAccumarrayFcnHandle)

spdiags Function: Improved performance constructing sparse banded


matrices
The performance of the spdiags function has improved by a factor of up to 3x when constructing
sparse banded matrices.

For example, if you create a large banded sparse matrix of order 1e7 with 11 nonzero diagonals,
performance in R2020b is about 2.6x faster than in R2020a.

function timingSpdiags
n = 1e7;
B = randn(n,11);
d = -5:5;

tic
A = spdiags(B, d, n, n);
toc
end

The approximate execution times are:

R2020a: 11.1 s

R2020b: 4.2 s

The code was timed on a Windows 10, Intel Xeon W-2133 CPU @ 3.60 GHz test system by calling the
function timingSpdiags.

7-40
Performance

uilistbox: Improved performance when setting multiple items in a list


box
Setting property values on a uilistbox shows improved performance when operating on a large
number of selected items. For example, this code is about 117x faster than in the previous release:

function timingTest
lb = uilistbox;
lb.Items = "Item " + (1:1000);
lb.ItemsData = 1:1000;
lb.Multiselect = true;
lb.Value = 1:800;
end

The approximate execution times are:

R2020a: 4.7 s

R2020b: 0.04 s

The code was timed on a Windows 10, Intel Xeon W-2133 CPU @ 3.60 GHz test system using the
timeit function:

timeit(@timingTest)

uitree: Improved performance when creating many nodes in a tree


The uitreenode function shows improved performance when creating a large number of nodes
parented to a uitree. For example, this code that creates a tree with 3,000 nodes is about 2.4x
faster than in the previous release:

function timingTest
t1to3000 = [];
fig = uifigure;
tree = uitree(fig);
drawnow
for i=1:3000
treeNodeText = ['t' num2str(i)];
t1to3000(i) = uitreenode('Parent',tree,'Text',treeNodeText);
end
drawnow
end

The approximate execution times are:

R2020a: 81.4 s

R2020b: 33.7 s

The code was timed on a Windows 10, Intel Xeon W-2133 CPU @ 3.60 GHz test system using the
timeit function:

timeit(@timingTest)

7-41
R2020b

Data Tip Markers: Improved rendering performance of data tip


markers in surface plots of large data sets created in UI figures and
MATLAB Online
In figures created with the uifigure function and in MATLAB Online, data tip markers for surface
plots of large data sets render faster and move more continuously in R2020b than in R2020a. This
improvement can be seen when the axes are created with either the axes or uiaxes function.

For example, on a Windows 10, Intel Xeon W-2133 CPU @ 3.6 GHz test system with an NVIDIA®
Quadro P600 graphics card, when you move your mouse quickly over the plot lines created by this
code, the data tip marker moves more smoothly and tracks your mouse motion more closely in
R2020b than in R2020a.

fig = uifigure;
ax = axes(fig);
surf(ax,peaks(75))

7-42
Software Development Tools

Software Development Tools

Code Compatibility Report: Unsupported Functionality Will Now Issue


Warning
The code compatibility report will now check and notify you of some unsupported functionality within
the code.

Dependency Analyzer: Export to archive and generate a dependency


report
Dependency analysis for projects is improved and includes new capabilities:

• Export files in the dependency graph to an archive.


• Save the dependency analysis results in a printable report.
• Investigate where in your files the dependency to a product is introduced.
• Determine which files, if any, use functionalities shared among different MathWorks products.

For more information, see Analyze Project Dependencies.

Source Control: Improved workflow to set up Git source control


The workflow to set up Git is improved and simplified.

• You do not need to install command-line Git to fully use Git with MATLAB. You can now merge
branches using the built-in Git integration.
• For newly created projects using Git and for projects that switched to Git from another source
control, MATLAB automatically generates a .gitattributes file and populates it with a list of
common binary files. You do not need to manually register binary files to prevent corruption.

For more information, see Set Up Git Source Control.

Projects: Change project definition file type and preserve source


control history
You can now use matlab.project.convertDefinitionFiles to programmatically change the
project definition file management from the type selected when you first created the project to a new
type. matlab.project.convertDefinitionFiles preserves the source control history of your
project. To avoid any merging issues, make sure to convert the definition file type only once for your
project.

Unit Testing Framework: Run tests in parallel on clusters and clouds


You can now run your tests on clusters and clouds using MATLAB Parallel Server. To run tests on a
remote parallel pool, use the same API the framework offers for running tests on a local parallel pool.
In other words, use the runInParallel method or the runtests function with the 'UseParallel'
name-value pair argument.

7-43
R2020b

Unit Testing Framework: Run tests in parallel with standalone


applications
Starting in R2020b, you can create standalone applications that support running tests in parallel. To
ensure that MATLAB Compiler can locate and package all of the components required for running
tests in parallel, use this directive in your program:

%#function parallel.Pool

For more information, see Compile MATLAB Unit Tests.

Unit Testing Framework: Report the validity of shared test fixtures


Starting in R2020b, you can report the validity of shared test fixtures to the testing framework. A
shared test fixture is valid if the test environment state, configured by the fixture, is maintained
throughout the test session.

To report the validity of a shared fixture, override the needsReset method of the
matlab.unittest.fixtures.Fixture class. When running multiple test classes as a single suite,
the framework tears down a shared test fixture and sets it up for the subsequent classes if
needsReset returns true.

App Testing Framework: Perform choose gestures on context menu


items
The chooseContextMenu method enables you to test choose gestures on context menu items for UI
components. For example, create a context menu with two menu items in a UI figure and choose one
of the menu items.
fig = uifigure;
cm = uicontextmenu(fig);
m1 = uimenu(cm,'Text','Menu1');
m2 = uimenu(cm,'Text','Menu2');
fig.ContextMenu = cm;

tc = matlab.uitest.TestCase.forInteractiveUse;
tc.chooseContextMenu(fig,m1)

App Testing Framework: Perform drag gestures on axes and UI axes


The app testing framework supports drag gestures on axes and UI axes. When you test a drag
gesture on an axes or UI axes, the framework mimics a user manipulating the component and adjusts
the axes limits based on the difference between the start and stop values. For example, create an
axes with a plot and then drag from the point (3, 2) to the point (4, 2).
f = uifigure;
ax = axes(f);
plot(ax,1:10)

tc = matlab.uitest.TestCase.forInteractiveUse;
tc.drag(ax,[3 2],[4 2])

App Testing Framework: Perform gestures on push tools and toggle


tools
The app testing framework supports gestures on more UI components.

7-44
Software Development Tools

• Perform press gestures in tests on push tools.


• Perform press and choose gestures in tests on toggle tools.

Functionality being removed or changed


SVN cleanup no longer removes unversioned or ignored files
Behavior change

Starting in R2020a Update 5, SVN cleanup only removes stale locks and unfinished transactions. It
does not remove unversioned or ignored files.

You can manually remove unversioned and ignored files.

1 In the Current Folder browser, click the SVN header to sort files by their SVN status.
2 Select the Not Under Source Control files.
3 Right-click and select Delete.

For more information, see Get SVN File Locks.

ProfileReport has been removed


Errors

The ProfileReport class has been removed. Use CoverageReport or CoberturaFormat instead.
Compared to ProfileReport, these two classes generate more accurate code coverage reports.

To update your code, change instances of ProfileReport to CoverageReport or


CoberturaFormat. This table shows an example of how you can update your code.

Before After
import matlab.unittest.TestRunner import matlab.unittest.TestRunner
import matlab.unittest.plugins.CodeCoveragePlugin
import matlab.unittest.plugins.CodeCoveragePlugin
import matlab.unittest.plugins.codecoverage.ProfileReport
import matlab.unittest.plugins.codecoverage.CoverageR

runner = TestRunner.withNoPlugins; runner = TestRunner.withNoPlugins;


plugin = CodeCoveragePlugin.forFolder('myTests',
plugin...
= CodeCoveragePlugin.forFolder('myTests', ...
'Producing',ProfileReport); 'Producing',CoverageReport);
runner.addPlugin(plugin) runner.addPlugin(plugin)

To create a MATLAB Profiler Coverage Report without specifying a ProfileReport format, see
Determine Code Coverage Using the Profiler.

Indexing order has changed in choose gestures within button groups


Behavior change

With the app testing framework, you can choose a radio button or toggle button using the button
label or its index inside the button group. Starting in R2020b, when you choose a radio button or
toggle button using an index, the framework indexes into the Buttons property of the ButtonGroup
object. In previous releases, the framework indexes into the Children property of the ButtonGroup
object. With this change, the index corresponds to the order in which buttons are created. For
example, create a button group that has six toggle buttons.

f = uifigure;
bg = uibuttongroup(f);

7-45
R2020b

tb1 = uitogglebutton(bg,'Position',[11 165 140 22],'Text','One');


tb2 = uitogglebutton(bg,'Position',[11 140 140 22],'Text','Two');
tb3 = uitogglebutton(bg,'Position',[11 115 140 22],'Text','Three');
tb4 = uitogglebutton(bg,'Position',[11 90 140 22],'Text','Four');
tb5 = uitogglebutton(bg,'Position',[11 65 140 22],'Text','Five');
tb6 = uitogglebutton(bg,'Position',[11 40 140 22],'Text','Six');

This table shows the outcome of the choose gesture on a toggle button that is specified with index 2.

Test Starting in R2020b R2020a and Earlier


MATLAB chooses toggle button
tc = matlab.uitest.TestCase.forInteractiveUse; MATLAB chooses toggle button
tc.choose(bg,2) tb2, which is the second tb5, which is the second
element of the bg.Buttons element of the bg.Children
array. The tc.choose(bg,2) array. The tc.choose(bg,2)
syntax is equivalent to syntax is equivalent to
tc.choose(bg,'Two'). tc.choose(bg,'Five').

If this behavior change impacts your code, update the index or replace it with the appropriate button
label.

7-46
External Language Interfaces

External Language Interfaces

C++ Interface: Support for nullptr


You can now pass nullptr to C++ functions. For more information, see nullptr Argument Types.

C++ Interface: Create interface with C++ source files


You can build a MATLAB interface to a C++ library or algorithm from source files that contain
complete implementations for the library. Use the SupportingSourceFiles name-value pair in the
clibgen.generateLibraryDefinition function. For an example, see Publish Interface to C++
Library Using Source Files.

Python: Version 3.8 support


MATLAB now supports CPython 3.8, in addition to existing support for 2.7, 3.6, and 3.7. For more
information, see Configure Your System to Use Python.

Python: Terminate Python interpreter and start new one in same


MATLAB session
When you run the Python interpreter in out-of-process mode, you can terminate the interpreter and
start a new one without restarting MATLAB. For more information, see Reload Out-of-Process Python
Interpreter.

mxCreateString C Matrix API functions: UTF-8 support


The C Matrix API mxCreateString function now accepts UTF-8 encoded data in addition to
supporting local code page (LCP) encoded strings for backwards compatibility. The
mxArrayToUTF8String function returns UTF-8 encoded data.

Also, the mexPrintf, mexEvalString, mexEvalStringWithTrap, mexErrMsgIdAndTxt, and


mexWarnMsgIdAndTxt C functions now accept UTF-8 encoded data in addition to supporting LCP
encoded strings for backwards compatibility.

MATLAB Data API: Create matlab::data::Object arrays


Use the matlab::data::ArrayFactory createArray method to create a
matlab::data::ObjectArray and the createScalar method to create a scalar
matlab::data::ObjectArray. You can use [] indexing and a
matlab::data::TypedIterator<T> to access the elements of a matlab::data::ObjectArray.

7-47
R2020b

Compiler support changed for building C++ interfaces, MEX files, and
standalone MATLAB engine and MAT-file applications
Support Compiler Platform
Added gcc versions 5.x and higher. If you use version 4.0 or Linux
earlier, then MATLAB displays a warning.

To ensure continued support for building your MEX files, consider upgrading to another supported
compiler. For an up-to-date list of supported compilers, see Supported and Compatible Compilers.

Functionality being removed or changed


Java packages to be removed
Behavior change in future release

Certain Java libraries (JAR files) used by MathWorks products might not be included in future
releases. To continue using functionality from these libraries, install the JAR files and add them to the
class path used by MATLAB. For information about adding JAR files to the static class path, see Static
Path.

Undocumented com.mathworks Java packages to be removed


Warns

The MATLAB Code Compatibility Report lists com.mathworks Java classes as Unsupported
functionality that might cause errors. Except for documented interfaces and classes in the
com.mathworks.engine and com.mathworks.matlab.types packages (the MATLAB Engine API
for Java) and the Java Client API for use with MATLAB Compiler SDK™ and MATLAB Production
Server™, all other com.mathworks Java interfaces and classes are undocumented and might be
modified or removed without warning in future releases. For code stability, avoid using any of these
undocumented Java interfaces or classes.

7-48
Hardware Support

Hardware Support

Live Editor Task: Interactively capture images from USB Webcam


interactively and generate MATLAB code in a live script.
Use the Acquire Webcam Image Live Editor Task in the MATLAB Support Package for USB
Webcams, to connect to a webcam, set properties, and capture images without writing MATLAB code.
The task provides you with controls that help you set webcam resolution values and other image-
specific and device-specific properties. The task also automatically generates MATLAB code that
becomes part of your live script.

To use tasks in the Live Editor, on the Live Editor tab, in the Task menu, select a task. Alternatively,
in a code block in a live script, begin typing the task name and select the task from the suggested
command completions. For more information about Live Editor tasks, see Add Interactive Tasks to a
Live Script (MATLAB).

Functionality being removed or changed


mkrMotorCarrier function will be removed in a future release
Warns

Starting R2020b, using the mkrMotorCarrier function will throw a warning message. This function
will be removed in a future release. Use the motorCarrier instead of mkrMotorCarrier to connect
to the MKR Motor Carrier hardware.

MKRMotorCarrier library will be removed in a future release


Warns

Starting R2020b, using the 'MKRMotorCarrier' library will throw a warning message. This library
will be removed in a future release. Use the 'MotorCarrier' library instead of
'MKRMotorCarrier' when creating a connection to the Arduino, hardware using the arduino
object.

7-49
8

R2020a

Version: 9.8

New Features

Bug Fixes

Compatibility Considerations
R2020a

Environment

Profiler Flame Graphs: Investigate and improve the performance of


your code visually
The redesigned Profiler now includes a flame graph that allows you to visually explore the execution
performance results of your code. You can use the flame graph to identify functions that use a
significant amount of time.

For example, this flame graph shows the performance results for a function called solvelotka. The
wide graphs represent the functions that use the most time. You can use the Profiler to explore those
functions and determine whether execution can be sped up.

For more information, see Profile Your Code to Improve Performance.

Live Editor Loop Execution: Improved performance when running


loops in live scripts
Loops run significantly faster in live scripts. For example, a live script containing this code, which
runs a loop one million times and displays the current loop iteration every ten thousand iterations, is
approximately 42x faster.

for t = 1:1000000
if ~mod(t, 10000)
disp(t)
end
end

The approximate execution times are:

R2019b: 2.291 s

R2020a: 0.054 s

The code was timed on a Windows 10 test system with a 3.6 GHz Intel Xeon CPU E5-1650 CPU by
running the above live script.

The more iterations a loop contains, the greater the performance improvement becomes.

8-2
Environment

Live Editor Animation Output: Improved performance when animating


plots in live scripts
For-loop animations display faster in live scripts. For example, a live script containing this code,
which creates a for-loop animation of a sine wave plot, is approximately 1.3x faster.

tic
x = 0:0.1:10*pi;
y = sin(x);
xlim([0 10*pi])
ylim([-1 1])
hold on
p = plot(x(1),y(1));
for k=1:length(x)
p.XData = x(1:k);
p.YData = y(1:k);
drawnow
end
toc

The approximate execution times are:

R2019b: 8.875 s

R2020a: 6.633 s

The code was timed on a Windows 10 test system with a 3.6 GHz Intel Xeon CPU E5-1650 CPU by
running the above live script.

Live Editor Responsiveness: Improved performance with extended use


The Live Editor maintains its interaction performance (such as typing and scrolling) when running
MATLAB over extended periods of time. In previous releases, the interaction performance of the Live
Editor decreased over time.

Live Editor Control Value Changes: Run all necessary code on value
changes
You can configure a control to run the current section and any stale code above it when the control
value changes. This ensures that when the value of the control changes, any modified or not yet run
sections above are run as well. To configure the control, right-click the control and select Configure
Control. Then, in the Run field, select the Current section and modified or not yet run sections
above option.

For more information about adding controls to a live script, see Add Interactive Controls to a Live
Script.

File Encoding: Save MATLAB code files (.m) and other plain text files
as UTF-8 encoded files by default
As of R2020a, MATLAB defaults to saving new plain text files using UTF-8 without a byte-order-mark
(BOM). This includes files created with the MATLAB Editor and the edit or fopen functions, as well

8-3
R2020a

as MATLAB log files and files created with the diary function. In the Editor, this includes all
MATLAB code files with a .m extension, such as scripts and functions. When opening existing files,
the Editor and other functions like type or fopen automatically determine the current encoding. The
Editor saves files with their current encoding unless a different one is selected from the Save As
dialog. For example, to save a file using the legacy locale-specific encoding for compatibility with an
earlier release of MATLAB, select Save > Save As... in the File section on the Editor tab. In the
dialog box that appears, select the desired encoding from one of the Save as type options.

MATLAB uses Unicode internally so that it can represent all letters and symbols, regardless of
platform, language, or locale. UTF-8 was adopted as MATLAB's default character encoding to ensure
that all Unicode code points can be correctly represented in files and byte streams. MATLAB also
supports other character encodings for backwards compatibility and interoperability. For more
information, see Locale Setting Concepts for Internationalization.

The current encoding is displayed next to the file name in the Editor status bar or, if the Editor
Window is docked, the Desktop status bar.

Multiple Sources in Help Browser: Search MathWorks documentation


and custom documentation together in a single browser
When you search the documentation in the Help browser, the Help browser displays both MathWorks
documentation results and installed custom documentation results. To switch between the two types
of results, use the Source facets that appear on the left side of the page. For example, to view the
MathWorks documentation results, select MathWorks as the source. To view the installed custom
documentation results, select Supplemental Software as the source.

Web Documentation: View MathWorks documentation on the web


without logging in
If your documentation preferences are set to view documentation on the web, you now can view the
documentation for most products without logging in.

For more information about setting your documentation location, see Help Preferences.

8-4
Environment

Internationalization: UTF-8 as system encoding on Mac and Windows


platforms
On the Mac platform, MATLAB uses UTF-8 as its system encoding to align with macOS.

On the Windows platform, if the Use Unicode UTF-8 for worldwide language support option is
enabled in the Windows Region settings dialog box, then MATLAB uses UTF-8 as its system
encoding.

8-5
R2020a

Language and Programming

switch Function: Compare objects more flexibly


MATLAB enables you to use objects of a class in switch statements if the objects support the eq
function. In previous releases, you can use objects of a class in switch statements only if the output
of the overloaded eq function is a logical value. Starting in R2020a, the output of eq can be either a
logical value or convertible to a logical value. For more information, see Objects In Conditional
Statements.

copyfile and movefile Functions: Access web-based storage services


like Amazon Web Services and Azure Blob Storage
You can now use the copyfile and movefile functions to work with remote files and folders. To
access remote locations, you must specify the full path using a uniform resource locator (URL). For
example, copy a file from Amazon S3 Cloud to the folder myFolder.
mkdir myFolder
copyfile s3://bucketname/path_to_file/my_image.jpg myFolder

For more information on setting up MATLAB to access your online storage service, see Work with
Remote Data.

dbup and dbdown Commands: Switch between workspaces with one


step
When you debug your code, you can now change the current workspace and function context to any
workspace and function context on the stack with one step. Specify the number of levels you want to
move on the stack as an input argument to the dbup and dbdown commands.

bin2dec and hex2dec Functions: Convert text that includes binary or


hexadecimal prefixes and suffixes
The bin2dec and hex2dec functions convert text inputs that include the same prefixes and suffixes
used for writing binary and hexadecimal literals.

For example, these calls to bin2dec return the same value:

bin2dec('111')
bin2dec('0b111')
bin2dec('0b111s32')

Similarly, these calls to hex2dec return the same value:

hex2dec('FF')
hex2dec('0xFF')
hex2dec('0xFFs32')

For more information on the syntax for using these prefixes and suffixes, see Hexadecimal and Binary
Values.

8-6
Language and Programming

dec2bin and dec2hex Functions: Convert negative numbers


The dec2bin and dec2hex functions convert negative numbers using their two's complement binary
values.

For example, these calls to dec2bin and dec2hex convert negative numbers.
dec2bin(-1)

ans =

'11111111'

dec2bin(-16)

ans =

'11110000'

dec2hex(-1)

ans =

'FF'

dec2hex(-16)

ans =

'F0'

complex Function: Create sparse complex arrays


You can now create sparse complex arrays from sparse input arguments using the complex function.

Enumeration classes: Hide member names for compatible name


changes
The enumeration block Hidden attribute enables enumeration class authors to hide member names
from class users. Hiding enumeration members enables you to replace existing names with new
names without introducing code incompatibilities. For more information, see Hide Enumeration
Members.

matlab.mixin.SetGet: Set priority for partial property name matching


Classes that derive from matlab.mixin.SetGet can use the PartialMatchPriority property
attribute to specify a relative priority for partial name matching. MATLAB applies this attribute when
resolving incomplete and case-insensitive text strings that match more than one property name. For
more information, see Set Priority for Matching Partial Property Names.

Class logical conversions: Support logical conversion more flexibly


when writing classes
When MATLAB requires a logical value for expressions like if and while statements, it attempts a
direct conversion using the logical converter function. If the result of the conversion is a nonlogical

8-7
R2020a

value, then MATLAB attempts to call the cast function with the "like" flag. If the class of the object
being converted defines a cast method that supports the "like" flag, and this method returns a
logical value, then MATLAB uses this logical value. Otherwise, MATLAB throws a
MATLAB:invalidConversion error.

Functionality being removed or changed


File Operations: Wildcard expression *.* on UNIX platforms matches only files that have an
extension
Behavior change

Starting in R2020a, on UNIX platforms, the wildcard expression *.* no longer matches folders or
files without an extension. In previous releases, the expression matches folders or files regardless of
extension, including files without an extension. This change of behavior does not apply to Microsoft
Windows platforms. This change affects the functions copyfile, delete, dir, movefile, and
rmdir.

copyfile Function: Symbolic links are treated consistently on platforms and file systems
Behavior change

Symbolic links (or symlinks) are file system objects that point to target files or folders. Starting in
R2020a, the behavior of the copyfile function changes when operating on symlink files or folders.

• Copy outcome is platform independent: copyfile now treats symlinks on different operating
systems in the same way. For example, consider a folder structure with a file myFile.m and a
symlink pointing to myFile.m, specified as symlinkToMyFile.

myFile.m
symlinkToMyFile

Starting in R2020a, copyfile('symlinkToMyFile','newFile') copies the target of the


symlink (that is, myFile.m) to the destination. In previous releases, on Linux, copyfile copies
the symlink instead.

Platform newFile (Starting in newFile (R2019b and


R2020a) Earlier)
Linux myFile.m symlinkToMyFile
Mac myFile.m myFile.m
Windows myFile.m myFile.m

• copyfile copies only the contents of the source folder: When copying a nonempty folder to
a symlink folder, copyfile now copies the contents of the source folder (that is, the files and
folders within the source folder) rather than the entire source folder. Similarly, when copying a
symlink folder to a destination folder, only the contents of the symlink folder are copied.

For example, consider a folder structure on Linux consisting of a nonempty folder myFolder and
a symlink to that folder named symlinkToMyFolder. This table shows the folder structure after
the execution of copyfile('myFolder','simlinkToMyFolder') in different MATLAB
releases.

8-8
Language and Programming

Folder Structure Before Folder Structure After Folder Structure After


Copy Copy (Starting in R2020a) Copy (R2019b and Earlier)
myFolder myFolder myFolder
myFile.m myFile.m myFile.m
symlinkToMyFolder symlinkToMyFolder symlinkToMyFolder
myFile.m myFolder
myFile.m

Toolbox folders renamed: Old names will be removed


Still runs

Various toolbox folders have been renamed. The old toolbox folder names passed to the toolboxdir,
ver, and verLessThan functions will be removed in a future release. Use the new names instead.

Toolbox Old Folder Name New Folder Name


Parallel Computing Toolbox distcomp parallel
Fixed-Point Designer™ fixpoint fixedpoint
Simulink Real-Time™ xpc slrt
Simscape™ Electrical™ powersys sps

System object authoring: StringSet will be removed


Still runs

The class matlab.system.StringSet will be removed in a future release to bring System object™
authoring closer to MATLAB classes.

System object syntax being removed Migration


Enumerated properties with Replace StringSets with enumerations or
matlab.system.StringSet property validators. See Limit Property Values to
Finite List.

System object authoring: Logical and Positive Integer property attributes will be removed
Still runs

The System object property attributes Logical and Positive Integer will be removed in a future
release to bring System object authoring closer to MATLAB classes.

System object syntax being removed Migration


Property attributes Logical and Positive Replace these property attributes with property
Integer validators. See Validate Property and Input
Values.

System object authoring: Several matlab.system.mixin.* classes will be removed


Still runs

These mixin classes will be removed in a future release:

• matlab.system.mixin.CustomIcon
• matlab.system.mixin.Nondirect

8-9
R2020a

• matlab.system.mixin.Propagates
• matlab.system.mixin.SampleTime

To simplify System object authoring, the functionality and methods from these classes are directly
included with the base System object class matlab.System.

System object syntax being removed Migration


• matlab.system.mixin.CustomIcon Remove any inheritance statements to these
• matlab.system.mixin.Nondirect classes from the beginning of your System object
class.
• matlab.system.mixin.Propagates
• matlab.system.mixin.SampleTime

ismethod Function: String and character vector in first input argument will be treated as
object
Behavior change in future release

In a future release, the ismethod function will treat a string or character vector in the first input
argument as a string or char object, instead of as the name of a class. To list the methods of a class
by referring to the class by name, use the methods function. To determine if a specific method name
is the name of a method of a class, use an expression like this:
any("methodName" == string(methods("ClassName"))

Constant properties: Defining a set or get access method for a constant property causes an
error

In previous releases, creating a set or get access method for a class property defined with the
Constant attribute resulted in a warning. MATLAB ignored these methods. Starting in R2020a,
MATLAB throws an error if a class defines access methods for Constant properties.

Constant properties: Specifying the Dependent attribute for a Constant property causes an
error

In previous releases, specifying the Dependent attribute for a class property defined with the
Constant attribute resulted in a warning. Starting in R2020a, MATLAB throws an error if a class
defines properties using both the Constant and Dependent attributes.

Property attributes: Specifying the Static attribute for a property causes an error

In previous releases, specifying the Static attribute for a class property resulted in a warning.
Starting in R2020a, MATLAB throws an error if a class defines properties using the Static attribute.

Property and method attributes: Specifying the Visible attribute for a property or method
causes an error

In previous releases, specifying the Visible attribute for a class property or method resulted in a
warning. Starting in R2020a, MATLAB throws an error if a class defines properties or methods using
the Visible attribute.

8-10
Language and Programming

Defining classes and packages: Using schema.m will not be supported in a future release
Still runs

Support for classes and packages defined using schema.m files will be removed in a future release.
Replace existing schema-based classes with classes defined using the classdef keyword.

empty static method: Inputs must be numeric or logical


Behavior change

In previous releases, the empty static method accepted inputs that are convertible to numeric or
logical values. Starting in R2020a, MATLAB throws an error if the inputs are not numeric, logical, or
values derived from numeric or logical classes.

For example, in releases prior to R2020a, passing the scalar char 'b' to empty produces a result
based on the Unicode numeric equivalent for the character b (which is the number 98).

a = double.empty(0,'b')

a =

0×98 empty double matrix

Starting in R2020a, the empty method does not accept inputs that are not numeric or logical.

a = double.empty(0,'b')

Error using double.empty


Value must be numeric or logical.

Calling superclass constructor: Stricter syntax is enforced


Behavior change

Subclass calls to superclass constructors cannot be part of other expressions, be contained in


conditional statements, or be made after references to the object. For more information on these
restrictions, see Subclass Constructors.

In previous releases, MATLAB did not identify certain syntaxes as calls to superclass constructors,
and therefore, did not throw errors caused by calling superclass constructors incorrectly. Starting in
R2020a, MATLAB more strictly enforces the correct syntax.

The following class code illustrates some of the cases where previous releases do not identify calls to
the superclass constructor because of the incorrect use of parenthesis or brackets.
classdef MyClass < A & B
methods
function obj = MyClass
obj = [obj@A] % Not idendified as superclass constructor call in previous releases
obj@B
(obj@B) % Not identified as a duplicate call to B constructor in previous releases
if 1
(obj@B) % Not identified as a conditional call in previous releases
end
(obj@A) % Not identified as called after object referenced in previous releases
end
end
end

8-11
R2020a

Data Analysis

Live Editor Tasks: Interactively manipulate tables and timetables, and


generate code
Use Live Editor tasks to stack, unstack, or synchronize tables and timetables. Interactively explore
the effects of your changes in output tables and timetables. The tasks also automatically generate
code that becomes part of your live script.

In R2020a, MATLAB offers four tasks for manipulating data in tables and timetables:

• Retime Timetable — Resample or aggregate timetable data.


• Stack Table Variables — Combine values from multiple table variables into one table variable.
• Synchronize Timetables — Retime and combine timetables to new time vector.
• Unstack Table Variables — Distribute values from one table variable to multiple table variables.

To open tasks in the Live Editor, use the Task menu on the Live Editor tab. For more information,
see Add Interactive Tasks to a Live Script.

Basic Fitting Tool: Fit lines to plotted data using modernized interface
Fit lines to plotted data using the modernized interface of the Basic Fitting tool. Open the tool by
selecting Tools > Basic Fitting from the figure toolbar.

For example, plot sample data.

load census
scatter(cdate,pop,'r')

Open the Basic Fitting tool. Select a fit and display the equation, R2 value, and root mean square
error (RMSE) value on the plot.

8-12
Data Analysis

detrend Function: Ignore NaN values


You can now ignore NaN values when computing trends with the detrend function using the
'omitnan' parameter.

accumarray Function: Maintain consistent output order on all


platforms
The accumarray function now returns results in the same order as they appear in the input on all
platforms.

Previously, if you used a function with accumarray that depended on the data order, such as @(x)
x(1), different platforms sometimes returned different results.

leapseconds Function: List all leap seconds used by the datetime data
type
To list all the leap seconds supported by the datetime data type, use the leapseconds function.
The output table that lists the leap seconds includes the dates on which they occurred, their signs,
and the cumulative adjustments. To determine the International Earth Rotation Service (IERS)
Bulletin C version number of the leap second data being used in MATLAB, also use the second output
argument. For more information, see IERS Bulletins.

To list leap seconds, use either of the following syntaxes:

T = leapseconds
[T,vers] = leapseconds

8-13
R2020a

timezones Function: Determine IANA Time Zone Database version


To determine the Internet Assigned Numbers Authority (IANA) Time Zone Database version
supported by the datetime data type, use the second output argument of the timezones function.

[T,vers] = timezones

For more information on the IANA Time Zone Database, see IANA Time Zone Database.

renamevars Function: Rename variables in table or timetable


You can rename variables in a table or timetable using the renamevars function.

rows2vars and unstack Function: Use naming rule to allow table and
timetable variable names with any characters
Starting in R2020a, you can specify the rule for naming table and timetable variables when you use
the rows2vars or unstack functions. Specify the rule using the 'VariableNamingRule' name-
value pair argument.

Value of 'VariableNamingRule' Rule


'modify' (default) Modify variable names to be valid MATLAB
identifiers
'preserve' Preserve original names that can have any
Unicode characters, including spaces and non-
ASCII characters.

Note: In some cases, the function must modify


original names even when 'preserve' is the
rule. Such cases include:

• Duplicate names
• Names that conflict with table dimension
names
• Names that conflict with a reserved name.
• Names whose lengths exceed the value of
namelengthmax.

Previously, these functions modified table and timetable variable names when necessary so that such
names were always valid MATLAB identifiers.

containsrange, overlapsrange, and withinrange Functions: Determine


if timetable row times intersect specified time range
To determine if the row times of a timetable intersect a specified time range, use one of these
functions.

8-14
Data Analysis

Function Purpose
containsrange Determine if timetable row times contain
specified time range
overlapsrange Determine if timetable row times overlap
specified time range
withinrange Determine if timetable row times are within
specified time range

tall Arrays: Operate on tall arrays with more functions, including


groupfilter and matches
The functions listed here now support tall arrays as inputs. For a complete list of supported functions,
type methods tall. For more information on usage and limitations, see the Extended Capabilities
section at the bottom of each reference page.

• groupfilter
• matches
• renamevars

In addition, some functions have updated or removed limitations with tall arrays.

Function Changes
ismember ismember now allows both inputs to be tall
arrays, as long as one of the inputs is the result of
a reduction operation along the first dimension
(such as sum or mean).

Previously, only one input could be a tall array.


vartype Many tall data analysis functions can now use
vartype to select data and grouping variables:

• Preprocessing functions with a


'DataVariables' name-value pair (such as
fillmissing, ischange, and smoothdata)
can use vartype to select the data variables.
• Grouping functions with groupvars and
datavars arguments (such as
grouptransform and groupsummary) can
use vartype to select the data and grouping
variables.

Previously, these functions could not use


vartype to select data or grouping variables.

8-15
R2020a

Function Changes
groupsummary and grouptransform groupsummary and grouptransform can now
operate on multidimensional variables in a tall
table or tall timetable.

Previously, these functions could only operate on


column vector variables.

Functionality Being Removed or Changed


The datetime function 'InputFormat' month formats M and MM do not recognize names,
and MMM does not recognize abbreviations
Behavior change

Starting in R2020a, when you specify month formats in the 'InputFormat' name-value pair
argument of the datetime function, the M and MM formats do not recognize month names. Also, the
MMM format recognizes only abbreviated names. In previous releases, all these formats recognized
both abbreviated and full month names.

For more information on formats, see the Format property of the datetime function.

Default aggregation function for nonnumeric data in unstack


Behavior change

In R2020a, if you do not specify the 'AggregationFunction' name-value pair argument of the
unstack function, then the default aggregation function for nonnumeric data is the unique function.
In previous releases, there was no default aggregation function for nonnumeric data, so unstack
would raise an error.

Behavior changes when the aggregation function has no data to aggregate in unstack
Behavior change

In R2020a, there are behavior changes when the aggregation function specified by the
'AggregationFunction' name-value pair argument of the unstack function has no data to
aggregate. This situation can occur when there are no data values that correspond to values in the
indicator variable after unstacking. In such cases, unstack essentially calls the aggregation function
on an empty array.

For more information on this change in behavior, see the Compatibility Considerations section of
unstack.

8-16
Data Import and Export

Data Import and Export

Datastores: Write data from datastore to files using writeall


You can write data from a datastore to files on disk using the writeall function.

Additionally, to add writeall functionality to custom datastores, you can use the new classes
matlab.io.datastore.FileWritable and
matlab.io.datastore.FoldersPropertyProvider. For more information, see Add Support for
Writing Data.

Datastores: Return timetables from tabularTextDatastore and


spreadsheetDatastore objects
tabularTextDatastore and spreadsheetDatastore objects have two new properties that
enable you to work with timetables: OutputType and RowTimes. These properties specify whether
the read, readall, and preview methods return tables or timetables.

Previously, these properties were only available in Parquet datastores.

Datastores: Partition and shuffle TransformedDatastore and


CombinedDatastore objects
You can now partition and shuffle arbitrarily nested transformations and combinations of datastores,
subject to these conditions:

• You can partition and shuffle a TransformedDatastore object only if all of its underlying
datastores can be partitioned and shuffled.
• You can partition and shuffle a CombinedDatastore object only if subset can be applied to all of
its underlying datastores. The underlying datastores can also be transformations or combinations
of datastores that can have subset applied to them.

Use isPartitionable and isShuffleable to test whether a CombinedDatastore object or a


TransformedDatastore object can be partitioned or shuffled, and to determine when certain
combinations of datastores are fit for parallel processing. isPartitionable and isShuffleable
return true when the underlying datastores can be partitioned or shuffled, respectively.

Datastores: Process files and blocks within files iteratively using


FileSet and BlockedFileSet objects
You can process a large collection of files when moving through the files iteratively using the
matlab.io.datastore.FileSet object. Similarly, you can process a large collection of blocks
within files iteratively using the matlab.io.datastore.BlockedFileSet object.

Parquet Files: Control encoding scheme and Parquet version when


writing files
The parquetwrite, parquetinfo, and write functions have two new name-value pairs:

8-17
R2020a

• 'VariableEncoding' controls whether a Parquet file uses plain or dictionary encoding for each
variable.
• 'Version' specifies whether to use Parquet 1.0 or Parquet 2.0 file formatting.

Text and Spreadsheet Files: Append, overwrite, or replace data using


'WriteMode' parameter
You can choose to append, overwrite, or replace data when writing to text and spreadsheet files by
using the WriteMode parameter with these functions:

• writetable
• writetimetable
• writematrix
• writecell

readtable Function: Uses results of detectImportOptions function by


default
Starting in R2020a, the readtable function uses the results of the detectImportOptions function
to import tabular data. In essence, these two readtable function calls behave identically.

T = readtable(filename)
T = readtable(filename,detectImportOptions(filename))

Compatibility Considerations
There are several differences between the default behavior of readtable and its default behavior in
previous releases. To call readtable with the default behavior it had up to R2019b, use the
'Format','auto' name-value pair argument.

T = readtable(filename,'Format','auto')

The table lists significant differences between the default behavior of readtable in R2020a and its
default behavior in previous releases.

Description of Input Fields or Default R2020a readtable Default Behavior in Previous


Rows Behavior Releases
First row does not have text to Assigns the names Converts the values in the first
assign as names of output table Var1,...,VarN as the names row of data values to the names
variables of output table variables of output table variables
Multiple rows of text as header • Ignore additional header • Import additional header
lines lines lines as text in the first rows
• Import values in remaining of output table
rows as detected data types • Import values in remaining
rows as text
Empty fields Treat as missing values for Treat as empty character
detected data type vectors or strings
Values in quotes Treat as detected data type Treat as text

8-18
Data Import and Export

Description of Input Fields or Default R2020a readtable Default Behavior in Previous


Rows Behavior Releases
Text that cannot be converted Treat as missing values for Treat as text
detected data type
Nonnumeric character trails Treat characters as nonnumeric Treat numeric and nonnumeric
numeric character without characters as though delimiter
delimiter between them separated them
Input text file has lines with Returns output table with extra Raises error message
different number of delimiters variables

textscan, readtable, detectImportOptions, and setvaropts Functions:


Read and import hexadecimal and binary literals
Hexadecimal and binary literals are now supported in the functions textscan, readtable,
detectImportOptions, and setvaropts. This list outlines the added capabilities of each function.

• textscan — Use the format specifier '%x' to read in data stored as hexadecimal data, and use
'%b' to read in data stored as binary data. The default data type is uint64. For example, res =
textscan('110101', '%b') will return res = 53 with the default data type uint64.
• readtable — Text that is prefixed with the characters '0x' is now treated as hexadecimal data
and text with the prefix '0b' is treated as binary data.
• detectImportOptions — Use the name-value pairs 'HexType' or 'BinaryType' to convert
the data from hexadecimal or binary to decimal, then set the data type of the output data. For
example, 'HexType', 'uint8' converts prefixed hexadecimal data to decimal, then sets the
data type of the output to an 8-bit unsigned integer during import.
• setvaropts — Set the data type and number system to be used when importing variables by
using these name-value pairs:

• 'Type' sets the data type of the resulting output variable. For example, 'Type','uint32'
sets the data type of the output variable to a 32-bit unsigned integer.
• 'NumberSystem' converts the number system of the input variable from hexadecimal or
binary to the decimal number system. For example, 'NumberSystem','hex' converts data
that is stored as hexadecimal to decimal data. If the number system of the input variable is
specified as 'decimal', then no conversion is applied. NumberSystem is also a new property
of the NumericVariableImportOptions object.

h5read and h5readatt: Read non-scalar string data as MATLAB string


arrays
The high-level HDF5 functions h5read and h5readatt now return HDF5 string arrays as MATLAB
string arrays rather than cell arrays of character vectors. Single (scalar) HDF5 strings are still
returned as MATLAB character vectors.

h5create and h5write: Write string data to HDF5 files


You can now write string data to HDF5 files using h5create and h5write instead of using low-level
HDF5 functions. String data can be specified as MATLAB character vectors or MATLAB string arrays.

8-19
R2020a

CDF Library: Upgraded to v3.7.0


The CDF library has been upgraded to version 3.7.0.

Tiff Object: Read and write the values of the Rational Polynomial
Coefficients tag
You can now read and write the values of the Rational Polynomial Coefficient (RPC) tag using the
RPCCoefficientTag tag for the Tiff object. For more information, see Table 6 in Exporting to
Images.

jsonencode: Customize encoding in MATLAB classes


You can overload the jsonencode function to customize the JSON encoding for a user-defined
MATLAB class. For an example, see Customize JSON Encoding for MATLAB Classes.

jsonencode: Encode enumerations


jsonencode encodes enumerations as strings. For example,

on = matlab.lang.OnOffSwitchState.on;
jsonencode(on)

ans =

'"on"'

Functionality being removed or changed


readtable, writetable, textscan, and similar functions use automatic character set
detection and UTF-8 encoding by default
Behavior change

As of R2020a, most functions that read text data use automatic character set detection to detect the
character encoding. Functions that use automatic character set detection include fileread,
textscan, readvars, readtable, readcell, readmatrix, and readtimetable.

Similarly, most functions that write text data use UTF-8 as the default character encoding. Using
UTF-8 provides interoperability between all platforms and locales without data loss or corruption.
Functions that use UTF-8 encoding by default include writematrix, writetable, writecell, and
writetimetable.

File I/O functions, such as fscanf and fprintf, use automatic character set detection and
UTF-8 encoding by default
Behavior change

As of R2020a, character-oriented file I/O functions such as fscanf, fgets, and fgetl trigger
automatic character set detection when reading a file that was opened using fopen without a
specified encoding.

Similarly, fprintf defaults to using UTF-8 encoding when writing a file that was opened using
fopen without a specified encoding.

8-20
Data Import and Export

h5write and h5writeatt use UTF-8 character encoding by default


Behavior change

UTF-8 is now the default character encoding for the high-level HDF5 functions h5write and
h5writeatt to ensure that all Unicode code points can be correctly represented in HDF5 files.

h5read and h5readatt return non-scalar string data as MATLAB strings


Behavior change

The high-level HDF5 functions h5read and h5readatt now return HDF5 string arrays as MATLAB
string arrays rather than cell arrays of character vectors. Single (scalar) HDF5 strings are still
returned as MATLAB character vectors.

web function does not return a handle or URL for pages that open your system browser
Behavior change

The web function does not return a handle or URL for pages that open in the system browser. This
includes all external pages, which by default open in your system browser, unless configured
otherwise in the MATLAB Web Preferences.

To update your code, remove the handle and URL output arguments from instances of the web
function. This table shows examples of how you can update your code.

Before After
[stat,h] = web('https://www.mathworks.com','-browser')
stat = web('https://www.mathworks.com','-browser')
[stat,h,url] = web('https://www.mathworks.com','-browser')
stat = web('https://www.mathworks.com','-browser')

hdftool has been removed


Errors

hdftool has been removed. To programmatically import HDF4 or HDF-EOS files, use the hdfread
function instead.

Importing HDF5 files using the Import Tool is no longer supported


Behavior change

The Import Tool no longer supports importing HDF5 files. To programmatically import HDF4 or HDF-
EOS files, use the hdfread function instead.

8-21
R2020a

Mathematics

nufft and nufftn Functions: Compute nonuniform fast Fourier


transforms
To compute 1-D or N-D fast Fourier transforms with nonuniform sampling, use the nufft and
nufftn functions, respectively.

sparse Function: Support for integer subscripts and logical


aggregation
The sparse function has two new capabilities:

• When you construct a sparse matrix using the syntax sparse(i,j,v), the subscript inputs i and
j can now be integer data types.
• When the third input of the syntax sparse(i,j,v) contains logical values and there are
repeated subscripts in i and j, the sparse function now applies a logical any operation to the
values with repeated subscripts.

8-22
Graphics

Graphics
boxchart Function: Visualize grouped numeric data by using box
charts
To create box charts, also called box plots, use the boxchart function. For each group of data, the
corresponding box chart displays the following information: the median, first and third quartiles,
outliers (computed using the interquartile range), and nonoutlier minimum and maximum values.
When you use vector data, you can use the first input argument xgroupdata to split your data into
groups and specify the positions of the corresponding boxes. When you use matrix data, boxchart
creates a separate box for each column in the matrix.

exportgraphics and copygraphics Functions: Save and copy graphics


with improved support for publishing workflows
Use the exportgraphics function to save the contents of any axes, figure, chart that can be a child
of a figure, tiled chart layout, or container such as a panel. This function provides a better alternative
to the print and saveas functions when you want to:

• Save graphics displayed in an app or in MATLAB Online.


• Minimize the white space around the content.
• Save a PDF fragment with embeddable fonts.
• Save a subset of the content in a figure.
• Control the background color.

The copygraphics function provides much of the same functionality as the exportgraphics
function, except that it copies the content to your system clipboard instead of saving it to a file. Use
this function to copy and paste content from MATLAB into other applications.

8-23
R2020a

ChartContainer Class: Develop charts that display a tiling of


Cartesian, polar, or geographic plots
Charts you develop as a subclass of matlab.graphics.chartcontainer.ChartContainer now
provide a TiledChartLayout object, which you can use to arrange one or more Cartesian axes,
polar axes, or geographic axes in your chart.

To access the TiledChartLayout object, call the getLayout method. To place one or more axes
objects into the layout, call the axes, polaraxes, or geoaxes function, and specify the
TiledChartLayout object as the first input argument. For more information, see Develop Charts
With Polar Axes, Geographic Axes, or Multiple Axes.

Tiled Chart Layout: Position, nest, and change the grid size of layouts
Customize layouts you create with the tiledlayout function by setting these properties on the
TiledChartLayout object:

• Position, InnerPositon, OuterPosition, and PositionConstraint — For changing the


size and location of the layout.
• GridSize — For changing the number of tiles along the rows and columns of the layout. You can
set this property only when the layout is empty.
• Layout — For configuring nested layouts. Nested layouts consist of at least two
TiledChartLayout objects, where the Parent property of one object is the other object.

pie Function: Specify a numeric format for the percentage labels


Specify the numeric format for the percentage labels on a pie chart. For example, you can specify the
number of decimal places or significant digits to display.

8-24
Graphics

Axes Convenience Functions: Pass an array of axes or chart objects to


convenience functions such as grid, hold, and box
Modify multiple axes or charts at one time by passing a vector of objects to the grid, hold, box,
xlabel, ylabel, zlabel, and title functions.

SeriesIndex and NextSeriesIndex Properties: Control how plots cycle


through colors and line styles
Set the SeriesIndex property on plot objects such as Line, Scatter, and Bar to control how the
objects vary in color and possibly line style. By default, the SeriesIndex for an object is a number
that corresponds to the object's order of creation. MATLAB uses the number to calculate indices into
the ColorOrder and LineStyleOrder properties of the axes. Changing the value of this property is
useful when you want to reassign the colors or line styles of the objects in the axes.

The NextSeriesIndex property on the axes maintains a count of the objects that have a
SeriesIndex property. MATLAB uses it to assign the value of the SeriesIndex property for each
new object in the axes. The count starts at 1 and increments for each additional object. The
NextSeriesIndex property is useful when you want to track how the objects cycle through the
colors and line styles.

For more information about controlling colors and line styles, see Control Colors, Line Styles, and
Markers in Plots.

colororder Function: Control colors in scatter histograms and parallel


plots
The colororder function now supports charts created with the scatterhistogram and
parallelplot functions.

pareto Function: Specify the fraction of the cumulative histogram to


include
Specify the fraction of the cumulative histogram to display in a Pareto chart as the last argument to
the pareto function. For example, this Pareto chart includes all the bars that make up 100% of the
cumulative histogram of Y.

Y = [50 20 15 15];
pareto(Y,1)

8-25
R2020a

Axes: Control margins for titles and labels by setting the


InnerPosition and PositionContraint properties
Set the InnerPositon property on any type of axes object to control the size and location of the plot
box.

Set the PositionConstraint property of an axes object or a chart that can be a child of a figure to
control the space around the plot box when you add or modify decorations such as titles and axis
labels. This property is similar to the existing ActivePositionProperty. However, unlike
ActivePositionProperty, the PositionConstraint property accepts the values
'outerposition' and 'innerposition' instead of 'outerpositon' and 'position'.

Built-In Axes Interactions: Explore data with cursors that show


available interactions
When you hover within a set of axes, the cursor changes to indicate when you can rotate axes, create
data tips, and pan axis rulers. For example, when you hover over ruler labels in 2-D axes, the cursor
indicates that you can drag to pan the axis ruler by changing to . When you hover over plots that
support data tips, the cursor indicates that you can click to create a data tip by changing to . You
can always drag to pan within 2-D axes and scroll to zoom, even when the cursor indicates another
interaction.

You can disable these cursor changes by setting the Pointer property of the figure.

scatter(1:10,1:10)
f = gcf;
f.Pointer = 'arrow';

8-26
Graphics

Built-In Axes Interactions: Customize built-in interactions on


geographic axes
By default, geographic axes include built-in pan, zoom, and data tip interactions. Enable and disable
the default built-in interactions for GeographicAxes objects using the
enableDefaultInteractivity and disableDefaultInteractivity functions.

You can create a customized set of built-in interactions by setting the Interactions property of a
GeographicAxes object. Specify the Interactions property as an array of ZoomInteraction,
PanInteraction, or DataTipInteraction objects. For more information, see Control Chart
Interactivity.

linkdata Function: Open dialog box to specify data sources using new
syntax
The linkdata function has a new syntax, linkdata showdialog, that opens the Linked Plot
Data Sources dialog box. Use the dialog box to interactively specify data sources for plotted data.

Alternatively, instead of calling linkdata showdialog, you can open the dialog box by clicking

Link/Unlink Plot in the figure toolbar.

Functionality being removed or changed


Most properties that accept the values 'on' or 'off' now return an OnOffSwitchState value
Behavior change

Most graphics object properties that accept the values 'on' or 'off' now accept and return a
matlab.lang.OnOffSwitchState value. For example, you can specify the Visible property of an
axes object as 'on', 'off', 1, 0, or a logical value. A value of 'on' is equivalent to true, and 'off'
is equivalent to false. Thus, you can use the value of the property as a logical value in a conditional
statement.

Any code that sets a property to 'on' or 'off' behaves the same way as in previous releases.
However, you might need to update code that checks the value of the property. This table describes
the most common situations.

Coding Pattern Example of Coding Pattern Updated Code


Checking for a specific obj.Visible(2) == 'n' obj.Visible == 1
character
Checking the data type isequal(class(obj.Visible),'char')
isequal(class(obj.Visible),...
'matlab.lang.OnOffSwitchState')
or
or
ischar(obj.Visible)
isa(obj.Visible,...
'matlab.lang.OnOffSwitchState')
Checking the value in a verifyEqual(testcase,obj.Visible,'on')
verifyEqual(obj.Visible,...
unit test matlab.lang.OnOffSwitchState.on)

ActivePositionProperty is not recommended


Still runs

8-27
R2020a

Setting or getting ActivePositionProperty on an axes or chart object is not recommended. Use


the PositionConstraint property instead.

There are no plans to remove ActivePositionProperty at this time, but the property is no longer
listed when you call the set, get, or properties functions on an axes or chart object.

To update your code, make these changes:

• Replace all instances of ActivePositionProperty with PositionConstraint.


• Replace all references to the 'position' option with the 'innerposition' option.

For example, the following code sets the axes ActivePositionProperty to 'position'.

ax = gca;
ax.ActivePositionProperty = 'position';

Here is the updated code, which has the same effect.

ax = gca;
ax.PositionConstraint = 'innerposition';

ChartContainer subclasses assign property values after the setup method runs
Behavior change

When you create an instance of a ChartContainer subclass, and pass property name-value pair
arguments to the constructor, the property values are assigned after the setup method runs. In
R2019b, the property values are assigned before the setup method runs.

If the setup method of your class references the value of a property on the object, you can update
your code in either of the following ways:

• Assign a default value for the property when you define it.
• Move the code that references the property to the update method.

Calling the ChartContainer.getAxes method returns an axes object as a child of a


TiledChartLayout object
Behavior change

When you call the getAxes method in a ChartContainer subclass, the method now returns an axes
object that is a child of a TiledChartLayout object. If there are no axes in the chart, getAxes
creates a Cartesian axes object. The chart no longer has an axes object until you create one by calling
the getAxes method or one of the axes creation functions: axes, polaraxes, or geoaxes.

As a consequence of these changes, the axes in your chart might not be the current axes. Your code
might produce unexpected results if you call the following types of functions within your class
methods without specifying the target axes object.

• Plotting functions — For example, plot, scatter, bar, or surf


• Functions that modify the axes — For example, hold, grid, or title

In R2019b, the axes object is a child of the chart object, and it is the current axes within the scope of
your class methods.

To update your code, specify the axes object as the first input argument when calling plotting
functions and functions that modify the axes.

8-28
Graphics

Implementing callbacks on geographic plots disables built-in interactions


Behavior change

Starting in R2020a, when you implement callbacks such as ButtonDownFcn on a geographic plot,
MATLAB automatically disables built-in interactions.

In previous releases, implementing callbacks did not disable built-in interactions on geographic plots.

Align Distribute Tool will be removed in a future release


Still runs

The Align Distribute Tool will be removed in a future release.

To control the arrangement of multiple plots in a figure, create a tiled chart layout using the
tiledlayout function instead.

To align or distribute graphics objects within a figure, select Tools > Align or Tools > Distribute
from the figure toolbar instead.

Charting functions return output only when you specify an output argument
Behavior change

The heatmap, geobubble, parallelplot, scatterhistogram, stackedplot, wordcloud,


xline, and yline functions no longer return the chart object as the ans variable when you call them
without specifying an output argument. This new behavior is consistent with the behavior of most
other charting functions.

In previous releases, the functions return the chart object as ans by default. If you have code that
references a chart object that is stored in the ans variable, update your code by assigning the output
to a different variable before referencing it.

8-29
R2020a

App Building
uicontextmenu Function: Add and configure context menu
components in apps and on the App Designer canvas
You can now create context menus in App Designer apps or in apps created with the uifigure
function. When you right-click a UI component that has a context menu assigned to it, a list of menu
items appears.

In apps created programmatically with the uifigure function, create a context menu using the
uicontextmenu function. Add menu items to it using the uimenu function. Then, assign it to a
component by setting the ContextMenu property of the component to the ContextMenu object.

In App Designer, create a context menu and assign it to a component by dragging it from the
Component Library onto the component. For more details, see Create and Edit Context Menus.

uitoolbar Function: Add custom toolbars to apps programmatically


To programmatically add custom toolbars to your App Designer app or your app created with the
uifigure function, use the uitoolbar function. Add push tools or toggle tools to the toolbar using
the uipushtool or uitoggletool functions.

Icon Property: Display SVG, animated GIF, or truecolor image array


icons in buttons and tree nodes
The Icon property of Button, ToggleButton, and TreeNode objects now supports SVG and
animated GIF files and truecolor image array data.

Mouse Pointer: Change the mouse pointer symbol in apps


You can now change the mouse pointer symbol in apps created with the uifigure function or in App
Designer to options such as 'hand' or 'crosshair', or you can create your own pointer symbol.

For apps created with the uifigure function, set the Pointer property of the Figure object. For
apps created with App Designer, select the component in the Component Browser. Then, in the
Inspector tab, select a pointer from the Pointer drop-down menu.

To create a custom pointer symbol, programmatically set the Pointer property value to 'custom',
and use the PointerShapeCData property to define the symbol. To specify the active pixel of a
custom pointer symbol, set the PointerShapeHotSpot property.

For more information, see UI Figure Properties.

Graphics Support: Create annotations, brush data, configure data


tips, save and copy graphics
You can now create annotations, brush data, configure data tips, and save or copy graphics in App
Designer apps or in apps created with the uifigure function.

To create annotations, use the annotation function.

8-30
App Building

Use brush mode to mark chart data interactively. Then, you can remove or replace marked data
values, or export values to the workspace. To turn on brush mode, select the data brushing button

from the axes toolbar or use the brush function to set the brush mode of the figure to 'on'.

Configure data tips in any of these ways:

• Edit data tip labels by double-clicking them.


• Display multiple pinned (persistent) data tips by clicking more than one data point in the plot.
• Click and drag pinned data tips to move their location with respect to the data point.
• View data tip options by right-clicking on a pinned data tip to display the context menu.

Save graphics displayed in an app using the exportgraphics or copygraphics function.

GUIDE to App Designer Migration Tool for MATLAB: Migrate GUIDE


apps to App Designer in less time and with fewer manual code
updates
Improvements to the migration tool significantly reduce the time and number of manual code updates
required to get your app running in App Designer. These improvements allow most of your app code
to work in App Designer with few or no manual changes required. For more information, see GUIDE
Migration Strategies.

The GUIDE to App Designer Migration Tool for MATLAB is available through the Add-On Explorer in
the MATLAB desktop or through File Exchange on MATLAB Central™.

App Testing Framework: Perform press gestures with different


selection types
The app testing framework supports mouse selection types in press gestures that are performed on
figures created with the uifigure function. To specify the selection type, use the
'SelectionType' name-value pair argument. For example:
fig = uifigure;
testCase = matlab.uitest.TestCase.forInteractiveUse;
testCase.press(fig,'SelectionType','open')

Functionality Being Removed or Changed


JavaContainer property will be removed in a future release
Warns

The JavaContainer property is undocumented and will be removed in a future release. Update your
code to use documented alternatives. For a list of documented functionality that you can use instead,
see Recommendations for MATLAB Apps Using Java & ActiveX on mathworks.com.

UIContextMenu property of graphics objects and UI components is not recommended


Still runs

Starting in R2020a, using the UIContextMenu property to assign a ContextMenu object to a


graphics object or UI component is not recommended. Use the ContextMenu property instead. The
new property can have the same values as the old one.

8-31
R2020a

There are no plans to remove support for the UIContextMenu property at this time. However, the
UIContextMenu property no longer appears in the list returned by calling the get function on a
graphics object or UI component.

Callback property of ContextMenu objects is not recommended


Still runs

Starting in R2020a, using the Callback property of a ContextMenu object is not recommended. To
specify behavior when you interact with a context menu, use the ContextMenuOpeningFcn property
of the ContextMenu object instead. The new property can reference callback functions in the same
way as the old one.

There are no plans to remove support for the Callback property of ContextMenu objects at this
time. However, this property no longer appears in the list returned by calling the get function on a
ContextMenu object.

Visible and Position properties of ContextMenu objects are not recommended


Still runs

Starting in R2020a, using the Visible and Position properties to configure a context menu to
open at a specific location is not recommended. In apps created with the uifigure function, use the
open function instead.

There are no plans to remove support for the Visible and Position properties of ContextMenu
objects at this time. However, these properties no longer appear in the list returned by calling the
get function on a ContextMenu object.

Font size and color of column and row headers in table UI components has changed
Behavior change

Starting in R2020a, table UI components created in App Designer or in figures created with the
uifigure function display column and row headers in a larger font size and darker font color. For
example, this code that creates a table UI component with table array data renders differently in
R2020a than it does in R2019b:

fig = uifigure;

dates = datetime([2016,01,17; 2017,01,20],'Format','MM/dd/uuuu');


m = [10; 9];
tdata = table(dates,m,'VariableNames',{'Date','Measurement'});

uit = uitable(fig,'Data',tdata);
uit.RowName = 'numbered';

8-32
Performance

Performance

Live Editor Loop Execution: Improved performance when running


loops in live scripts
Loops run significantly faster in live scripts. For example, a live script containing this code, which
runs a loop one million times and displays the current loop iteration every ten thousand iterations, is
approximately 42x faster.

for t = 1:1000000
if ~mod(t, 10000)
disp(t)
end
end

The approximate execution times are:

R2019b: 2.291 s

R2020a: 0.054 s

The code was timed on a Windows 10 test system with a 3.6 GHz Intel Xeon CPU E5-1650 CPU by
running the above live script.

The more iterations a loop contains, the greater the performance improvement becomes.

Live Editor Animation Output: Improved performance when animating


plots in live scripts
For-loop animations display faster in live scripts. For example, a live script containing this code,
which creates a for-loop animation of a sine wave plot, is approximately 1.3x faster.

tic
x = 0:0.1:10*pi;
y = sin(x);
xlim([0 10*pi])
ylim([-1 1])
hold on
p = plot(x(1),y(1));
for k=1:length(x)
p.XData = x(1:k);
p.YData = y(1:k);
drawnow
end
toc

The approximate execution times are:

R2019b: 8.875 s

R2020a: 6.633 s

The code was timed on a Windows 10 test system with a 3.6 GHz Intel Xeon CPU E5-1650 CPU by
running the above live script.

8-33
R2020a

datetime, duration, and calendarDuration Data Type Indexing:


Improved performance when assigning elements by subscripting
datetime, duration, and calendarDuration subscripted assignment is significantly faster.
Performance is now essentially constant with the number of elements in an array.

• For example, when you assign into a datetime array with 106 elements, performance in R2020a
is approximately 25x faster than in R2019b, as shown below.

function timingTest()
dt = datetime + hours(1:1e6);
indices = randi(1e6,1,10000);
rhs = NaT;

tic;
for i = indices
dt(i) = rhs;
end
toc
end

The approximate execution times are:

R2019b: 0.42 s

R2020a: 0.017 s
• Similarly, assignment into a duration array is faster. For example, when you assign into a
duration array with 106 elements, performance in R2020a is approximately 11x faster than in
R2019b.

function timingTest()
d = hours(1:1e6);
indices = randi(1e6,1,10000);

tic;
for i = indices
d(i) = NaN;
end
toc
end

The approximate execution times are:

R2019b: 0.43 s

R2020a: 0.039s

The code was timed on a Windows 10, Intel Xeon W-2133 @ 3.60 GHz test system by calling the
function timingTest.

These performance improvements occur only when you make subscripted assignments within a
function. There is no improvement when subscripting into datetime, duration, and
calendarDuration arrays at the command line, or within try-catch blocks.

8-34
Performance

datetime Data Type Format Parsing: Improved performance when


parsing format of text inputs
datetime parsing performance is significantly faster when parsing the format of text inputs. For
example, this code parses the date format of a string using the datetime function. The code
executes approximately 1.75x faster in R2020a than in R2019b.
function timingTest()
d1 = datetime(2010,1,1:10000);
s = string(d1,'dd-MMM-uuuu');
tic
for i = 1:100, d2 = datetime(s); end
toc
end

The approximate execution times are:

R2019b: 5.44 s

R2020a: 3.10 s

The code was timed on a Windows 10, Intel Xeon W-2133 @ 3.60 GHz test system by calling the
function timingTest.

table Data Type Indexing: Improved performance when assigning


elements by subscripting into table variables
table subscripted assignment into table variables is significantly faster. Performance is essentially
constant with the number of elements in each table variable.

• For example, when you use dot indexing to assign elements to a variable with 106 elements,
performance in R2020a is approximately 2x faster than in R2019b, as shown below.
function timingTest()
t = table(zeros(1e6,1));
indices = randi(1e6,1,10000);

tic;
for i = indices
t.Var1(i) = rand;
end
toc
end

The approximate execution times are:

R2019b: 1.20 s

R2020a: 0.59 s
• Similarly, assignment using curly braces is faster. When you assign into three table variables with
106 elements, performance in R2020a is approximately 1.2x faster than in R2019b, as shown
below.
function timingTest()
t = table(zeros(1e6,1), ones(1e6,1), nan(1e6,1));

8-35
R2020a

indices = randi(1e6,1,10000);

tic;
for i = indices
t{i,:} = rand;
end
toc
end

The approximate execution times are:

R2019b: 8.04 s

R2020a: 6.68 s

The code was timed on a Windows 10, Intel Xeon W-2133 @ 3.60 GHz test system by calling the
function timingTest.

The performance improvement occurs only when you make table subscripted assignments within a
function. There is no improvement when subscripting into tables at the command line, or within try-
catch blocks.

Subscripted Reference: Improved performance for struct arrays


stored in a property of an object
The performance of indexing into struct arrays that are stored in a property of a MATLAB object
has improved. For example, this code executes about 2.3x faster in R2020a:
classdef ContainerClass
properties
field
end
end

function out = timingTest

M = struct('f', 1);
M(2) = struct('f', 2);
C = ContainerClass;
C.field = M;

tic
for j = 1:4e5
out = C.field(1);
end
toc

end

The approximate execution times are:

R2019b: 1.14 s

R2020a: 0.5 s

The code was timed on a Windows 10, Intel Xeon W-2133 @ 3.60 GHz test system by calling the
function timingTest.

8-36
Performance

imread Function: Improved performance in reading JPEG images


The imread function shows improved performance when reading JPEG images. The higher the image
resolution (measured in pixels), the greater the performance improvement becomes.

For example, a JPEG image with a resolution of 5120x3840 is read about 2.1x faster in R2020a:

function out = testperformance(filename)


for ii = 1:100
tic
imread(filename);
ts(ii) = toc;
end
out = mean(ts)
end

The approximate execution times are:

R2019b: 0.46s

R2020a: 0.22s

The code was timed on a Windows 10, Intel Xeon® CPU E5-1650 @ 3.6 GHz test system by calling
the function testperformance.

readmatrix Function: Improved performance in reading data


The readmatrix function shows improved performance when reading matrix data. The larger the
matrix to be read, the greater the performance improvement becomes.

For example, a matrix that is 30,000 x 30,000 elements in size is read about 1.1x faster in R2020a:

function out = readmatrix_performance()


M = randi(10,30000);
writematrix(M);
for ii = 1:10
tic
readmatrix('M.txt');
ts(ii) = toc;
end
out = mean(ts);

The approximate execution times are:

R2019b: 225.21s

R2020a: 198.42s

The code was timed on a Windows 10, Intel Xeon® CPU E5-1650 @ 3.6 GHz test system by calling
the function readmatrix_testperformance.

8-37
R2020a

ode15s, ode23t, and ode15i Solvers: Improved performance solving


differential equations
The ode15s, ode23t, and ode15i solvers show improved performance solving differential equations.
The performance improvement gets better as the number of linear systems evaluated by the solver
during the solution process increases.

• For ode15s, this code executes about 3.5x faster in R2020a:

function timingOde15s
[t,y] = ode15s(@vdp1000,[0 1e5],[2; 0]);
end

The approximate execution times are:

R2019b: 2.83 s

R2020a: 0.82 s
• For ode23t, this code executes about 4.1x faster in R2020a:

function timingOde23t
[t,y] = ode23t(@vdp1000,[0 1e5],[2; 0]);
end

The approximate execution times are:

R2019b: 2.92 s

R2020a: 0.72 s
• For ode15i, this code executes about 2.3x faster in R2020a:

function timingOde15i
[y0,yp0] = decic(@weissinger,1,sqrt(3/2),1,0,0);
for k = 1:100
[t,y] = ode15i(@weissinger,[1 10],y0,yp0);
end
end

The approximate execution times are:

R2019b: 0.51 s

R2020a: 0.22 s

All timings were performed on a Windows 10, Intel Xeon W-2133 CPU @ 3.60 GHz test system using
the timeit function:

timeit(@timingOde15s)
timeit(@timingOde23t)
timeit(@timingOde15i)

8-38
Performance

transpose and ctranspose Functions: Improved performance on large


arrays
The performance of the transpose and ctranspose functions (.' and ' operators) has improved
when operating on large arrays. For example, this code executes about 4.4x faster in R2020a when
transposing a 10,000-by-10,000 matrix:

function timingTest
rng default
A = rand(1e4);
tic
At = A';
toc
end

The approximate execution times are:

R2019b: 0.61 s

R2020a: 0.14 s

The code was timed on a Windows 10, Intel Xeon CPU E5-1650 v3 @ 3.50 GHz test system by calling
the function timingTest.

ordschur and ordqz Functions: Improved performance operating on


large matrices
The ordschur and ordqz functions show improved performance when operating on square matrices
of order 200 or greater. The performance improvement gets better as the matrix gets larger.

• For ordschur, this code executes about 11.3x faster in R2020a:

function timingOrdschur
rng default
A = randn(2000);
[U,S] = schur(A,'real');
tic
[U,S] = ordschur(U,S,'lhp');
toc
end

The approximate execution times are:

R2019b: 3.5 s

R2020a: 0.31 s
• For ordqz, this code executes about 8.3x faster in R2020a:

function timingOrdqz
rng default
A = randn(2000);
B = randn(2000);
[A,B,Q,Z] = qz(A,B,'complex');
tic
[A,B,Q,Z] = ordqz(A,B,Q,Z,'lhp');

8-39
R2020a

toc
end

The approximate execution times are:

R2019b: 18.2 s

R2020a: 2.2 s

All timings were performed on a Windows 10, Intel Xeon W-2133 CPU @ 3.60 GHz test system by
calling the functions timingOrdschur and timingOrdqz.

sparse Function: Improved performance constructing sparse matrices


The sparse function shows improved performance constructing sparse matrices. The performance
improvement applies to all syntaxes of the function and gets better as the constructed matrix gets
larger.

For example, this code executes about 4.4x faster in R2020a:


function timingSparse
m = 1e5;
n = 1e3;
nz = 1e7;
rng default
i = randi(m,nz,1);
j = randi(n,nz,1);
v = rand(nz,1);

tic
A = sparse(i,j,v,m,n);
toc
end

The approximate execution times are:

R2019b: 1.68 s

R2020a: 0.38 s

The code was timed on a Windows 10, Intel Xeon W-2133 CPU @ 3.60 GHz test system by calling the
function timingSparse.

interp1 Function: Faster interpolation for small problem sizes


The interp1 function shows improved performance for problems with less than about 10,000 sample
points. The improvement applies to all interpolation methods.

For example, this code executes about 2.5x faster in R2020a:


function timingInterp1
x = 1:100;
v = sin(x/3);
xq = 1:0.5:100;

for k = 1:10000

8-40
Performance

vq = interp1(x,v,xq);
end
end

The approximate execution times are:

R2019b: 0.42 s

R2020a: 0.17 s

The code was timed on a Windows 10, Intel Xeon W-2133 CPU @ 3.60 GHz test system using the
timeit function:
timeit(@timingInterp1)

assert Function: Improved performance for most common use cases


The performance of the assert function has significantly improved, making it virtually penalty-free
to use assertions in error handling applications. For example, this code executes approximately 300x
faster in R2020a:
function testAssertPerformance
x = -1;
for i = 1:1e6
assert(x == -1,'Sample error message.')
end
end

The approximate execution times are:

R2019b: 0.30 s

R2020a: 0.001 s

The code was timed on a Windows 10, Intel Xeon CPU E5-1650 v4 @ 3.60 GHz test system using the
timeit function:
timeit(@testAssertPerformance)

There is no performance improvement if assert is called with an error message that contains
formatting conversion characters, such as those used with the MATLAB sprintf function.

nexttile Function: Improved performance when creating several axes


in a tiled chart layout
The nexttile function shows improved performance when creating several axes in a tiled chart
layout. The performance improvement gets better as the number of axes increases.

For example, this code creates 100 axes in a 10-by-10 layout. It executes about 7.2x faster in R2020a.
function timingTest
tiledlayout(10,10);
for i = 1:100
nexttile;
end
end

8-41
R2020a

The approximate execution times are:

R2019b: 3.6 s

R2020a: 0.5 s

All timings were performed on a Windows 10, Intel Xeon W-2133 CPU @ 3.60 GHz test system using
the timeit function:
timeit(@timingTest)

App Designer Code View: Improved performance when displaying and


editing code in App Designer
Displaying and editing code in the App Designer Code View editor is faster in R2020a than in
R2019b. This affects actions like entering text, creating a new line of code, and adding and deleting
functions.

In apps with approximately 2500 lines of code and 4500 lines of code, these types of improvements
can be seen:

• Switching from Design View to Code View is about 1.5x faster in apps with approximately 2500
lines of code, and about 1.6x faster in apps with approximately 4500 lines of code.

The approximate execution times are:

Release ~2500 Lines of Code ~4500 Lines of Code


R2019b 0.63 s 1.10 s
R2020a 0.42 s 0.70 s
• Entering text in the Code View editor is about 2.8x faster in apps with approximately 2500 lines
of code, and about 3.9x faster in apps with approximately 4500 lines of code.

The approximate execution times are:

Release ~2500 Lines of Code ~4500 Lines of Code


R2019b 3.97 s 6.67 s
R2020a 1.44 s 1.72 s
• Creating a new line of code by pressing Enter in the Code View editor is about 5.8x faster in apps
with approximately 2500 lines of code, and about 9.4x faster in apps with approximately 4500
lines of code.

The approximate execution times are:

Release ~2500 Lines of Code ~4500 Lines of Code


R2019b 1.33 s 3.38 s
R2020a 0.23 s 0.36 s
• Adding and deleting a function in apps with approximately 2500 lines of code are about 1.7x and
2.9x faster, respectively.

The approximate execution times are:

8-42
Performance

Release Add Delete


R2019b 0.12 s 0.086 s
R2020a 0.07 s 0.030 s

Similarly, in apps with approximately 4500 lines of code, adding and deleting a function are about
1.8x faster and 2.8x faster, respectively.

The approximate execution times are:

Release Add Delete


R2019b 0.18 s 0.13 s
R2020a 0.10 s 0.046 s

These actions were timed on a Windows 10, Intel Xeon® CPU E5-1650 v3 @ 3.5GHz test system with
NVIDIA Quadro K620 graphics card.

Graphics Rendering in UI Figures: Improved graphics rendering


performance on large data sets in UI figures
In figures created with the uifigure function, the graphics rendering performance on large data
sets is improved in some cases, such as when displaying these types of plots:

• Surface plots of data larger than a 300-by-300 matrix


• Scatter plots with 20,000 markers or more
• Images where the data stored in the CData property is greater than 1 KB

In cases like these, the larger the data set, the greater the performance improvement becomes. These
examples show the improvements:

• This code creates the surface plot approximately 5.9x faster in R2020a:
function timingTestSurface
num = 10;
tocTimes = zeros(1,num);
fig = uifigure;
ax = uiaxes(fig);
drawnow

for k=1:num
tic
s = surface(ax,peaks(500));
s.EdgeColor = 'none';
drawnow
tocTimes(k) = toc;
delete(s)
drawnow
end

disp(['Average Time: ' num2str(mean(tocTimes))])

end

The approximate execution times are:

8-43
R2020a

R2019b: 3.019 s

R2020a: 0.5102 s
• This code creates the scatter plot approximately 1.1x faster in R2020a:

function timingTestScatter
num = 10;
tocTimes = zeros(1,num);
fig = uifigure;
ax = uiaxes(fig);
drawnow
x = linspace(0,3*pi,20000);
y = cos(x) + rand(1,20000);

for k=1:num
tic
s = scatter(ax,x,y);
drawnow
tocTimes(k) = toc;
delete(s)
drawnow
end

disp(['Average Time: ' num2str(mean(tocTimes))])

end

The approximate execution times are:

R2019b: 0.0952 s

R2020a: 0.0890 s
• This code displays a 650-by-600-by-3 truecolor image array (1.17 MB) approximately 1.5x faster in
R2020a:

function timingTestImage
num = 10;
tocTimes = zeros(1,num);
C = imread('ngc6543a.jpg');
fig = uifigure;
ax = uiaxes(fig);
drawnow

for k=1:num
tic
im = image(ax,C);
drawnow
tocTimes(k) = toc;
delete(im)
drawnow
end

disp(['Average Time: ' num2str(mean(tocTimes))])

end

The approximate execution times are:

8-44
Performance

R2019b: 0.0903 s

R2020a: 0.0588 s

This code was timed on a Windows 10, Intel Xeon® CPU E5-1650 v4 @ 3.6 GHz test system with
NVIDIA Quadro K620 graphics card by calling the timingTestSurface, timingTestScatter, and
timingTestImage functions.

Data Tip Markers: Improved rendering performance of data tip


markers in line plots of large data sets created in UI figures and
MATLAB Online
In figures created with the uifigure function and in MATLAB Online, data tip markers for line plots
of large data sets render faster and move more continuously in R2020a than in R2019b. This
improvement can be seen when the axes are created with either the axes or uiaxes function.

For example, on a Windows 10, Intel Xeon® CPU E5-1650 v4 @ 3.6 GHz test system with NVIDIA
Quadro K620 graphics card, when you move your mouse quickly over the plot lines created by this
code, the data tip marker moves more smoothly and tracks your mouse motion more closely in
R2020a than in R2019b.

fig = uifigure;
ax = axes(fig);
plot(ax,magic(300));

Icon Property: Improved rendering performance for buttons and tree


nodes with icons
Creating Button, ToggleButton, and TreeNode objects with icons using the Icon property is
significantly faster. The performance improvement gets better the larger the icon file size, or the
more components with icons you have in your app.

For example, this code creates a button with an icon (file size 2.86 MB) approximately 4.6x faster in
R2020a:

function timingTestButton
r = rand(1000,1000,3);

8-45
R2020a

imwrite(r,'testimage.png')
num = 10;
tocTimes = zeros(1,num);
fig = uifigure;
drawnow

for k = 1:num
tic
btn = uibutton(fig,'Icon','testimage.png');
drawnow
tocTimes(k) = toc;
end

disp(['Average Time: ' num2str(mean(tocTimes))])

end

The approximate execution times are:

R2019b: 0.705 s

R2020a: 0.154 s

This code was timed on a Windows 10, Intel Xeon® CPU E5-1650 v4 @ 3.6 GHz test system with
NVIDIA Quadro K620 graphics card by calling the timingTestButton function.

Functionality being removed or changed


bench Function: Problem sizes have increased for numerical computation tasks
Behavior change

Starting in R2020a, problem sizes have increased for the numerical computation tasks (LU, FFT, ODE,
and Sparse) so that the ranking of machines using bench test results are not dominated by the 2-D
and 3-D graphics tasks. In previous releases, the 2-D and 3-D tasks take significantly longer to
complete compared to the numerical computation tasks and therefore contribute disproportionately
to the ranking of machines.

This table shows different task execution times in R2020a using a Windows 10, Intel Xeon W-2133 @
3.60 GHz test system. The measured values are expressed in seconds.

Test New Problem Sizes Old Problem Sizes


LU 0.388 0.068
FFT 0.312 0.112
ODE 0.480 0.015
Sparse 0.488 0.103
2-D 0.301 0.307
3-D 0.296 0.303

8-46
Software Development Tools

Software Development Tools


Dependency Analyzer: Improved navigation, filtering, and highlighting
for project dependencies
In R2020a, use the new Dependency Analyzer to analyze project dependencies with improved
navigation, filtering, and highlighting.

On the Project tab, in the Tools section, click Dependency Analyzer.

Run a dependency analysis to:

• Visualize the project structure and dependencies when you setup or explore a project for the first
time. For more details, see Explore the Dependency Graph, Views, and Filters.
• Find products and toolboxes required by your design. For more details, see Find Required
Products and Toolboxes.
• Investigate and resolve problems before sharing, packaging or submitting your project to source
control. For more details, see Investigate and Resolve Problems.
• Assess the impact of the changes you made on the rest of the design. For more details, see Find
File Dependencies.

8-47
R2020a

For an example showing how to perform an impact analysis to find and run the tests affected by
modified files, see Perform Impact Analysis with a Project (Simulink).

Behavior Change

Workflow R2019b R2020a


Examine project dependencies At the top right of the In the Dependency Analyzer,
and problem files using the file Dependency Analysis view, click File List.
list. select Table View.
MATLAB opens the file list in
MATLAB switches to the file list the same view as the graph. See
view. Investigate and Resolve
Problems.
Investigate how two files are Expand the file in the graph by Select the dependency arrow. In
related and highlight where the clicking the arrows next to the the Properties pane, in the
dependency is introduced. file name. To highlight the Details section, you can see the
dependency, double-click the full paths of the files you are
line number in the expanded examining, the dependency
file. type, and where the dependency
is introduced.

To highlight where the


dependency is introduced, in the
Details section, click the link
under Impacted. See
Investigate Dependency
Between Two Files.
Color files in the dependency On the Dependency Analysis In the Dependency Analyzer, in
graph by type, source control tab, in the Group By menu, the Views section, use the
status, or label. select the option you want. different views to explore your
project files dependencies. See
Explore the Dependency Graph,
Views, and Filters.

Project Checks: Run all project checks programmatically


You can now use runChecks to run all project checks programmatically.

Project API: Get latest Git revision programmatically


You can now programmatically get the latest Git revision for every file in your project.

For a project under Git source control, use currentProject to create a project object from the
currently loaded project.

proj = currentProject;

Get the latest Git revision of the project file number fileNumber.

proj.Files(fileNumber).Revision

For an example on how to get the latest revisions for modified files, see List Modified Files in Project.

8-48
Software Development Tools

Unit Testing Framework: Add custom details to TestResult objects


Starting in R2020a, you can add data to the Details property of TestResult objects when you
create your plugins. To append a field to the Details structure, use the append method of the
matlab.unittest.plugins.plugindata.ResultDetails class. For more information, see Write
Plugin to Add Data to Test Results.

Unit Testing Framework: Assert that test session ran with no failure
The matlab.unittest.TestResult class has a new method assertSuccess, which enables you
to assert that no failing conditions were encountered during a test session. For example, run the tests
defined in MyTestClass and assert that none of them failed.
result = assertSuccess(runtests('MyTestClass'));

Unit Testing Framework: Run tests from the Live Editor toolstrip
You can now run tests from the MATLAB Live Editor toolstrip. When you open a function-based test
file with a .mlx extension, the Live Editor toolstrip has options to:

• Run all tests in the file.


• Run the test at your cursor location.

You can customize the test run with options, such as running tests in parallel (which requires Parallel
Computing Toolbox) or running tests with a specified level of output detail.

Unit Testing Framework: Generate test reports including test tags


Starting in R2020a, test reports generated using the TestReportPlugin class display the test tags
for tagged test suite elements. You can generate tagged test reports in DOCX, HTML, and PDF
formats. For information about test tags, see Tag Unit Tests.

App Testing Framework: Perform press gestures with different


selection types
The App testing framework supports mouse selection types in press gestures that are performed on
UI figures. To specify the selection type, use the 'SelectionType' name-value pair argument. For
example:
f = uifigure;
testCase = matlab.uitest.TestCase.forInteractiveUse;
testCase.press(f,'SelectionType','open')

Mocking Framework: Add events to mock objects


When creating a mock object, you can add events to the object in addition to properties and methods.
To specify the events to mock, use the createMock method with the 'AddedEvents' name-value
pair argument. To add events to the mock, the mock object must derive from a handle class. For
example:
testCase = matlab.mock.TestCase.forInteractiveUse;
[mock,behavior] = testCase.createMock(?handle,'AddedEvents',{'EventA','EventB'});

8-49
R2020a

Mocking Framework: Specify when framework should do nothing


You can specify that the unit testing framework should do nothing each time a mock object method is
called or a mock object property is set. Define this behavior with the
matlab.mock.actions.DoNothing class.

For example, create a mock object with a property PropA. Define behavior such that the property is
unchanged when it is assigned a value of 0:
testCase = matlab.mock.TestCase.forInteractiveUse;
[mock,behavior] = testCase.createMock('AddedProperties',"PropA");

import matlab.mock.actions.DoNothing
when(behavior.PropA.setToValue(0),DoNothing);

Use the mock to assign a nonzero value to PropA.


mock.PropA = 5

mock =

Mock with properties:

PropA: 5

Assign a value of 0 to the property. Due to the defined mock object behavior, the value of PropA
remains unchanged.
mock.PropA = 0

mock =

Mock with properties:

PropA: 5

Functionality being removed or changed


ProfileReport will be removed in a future release
Warns

The ProfileReport class will be removed in a future release. Use CoverageReport or


CoberturaFormat instead. Unlike ProfileReport, which supports running tests only in serial
mode, these two classes can be used to generate reports when tests run in either serial or parallel
mode.

To update your code, change instances of ProfileReport to CoverageReport or


CoberturaFormat. This table shows an example of how you can update your code.

Before After
import matlab.unittest.TestRunner import matlab.unittest.TestRunner
import matlab.unittest.plugins.CodeCoveragePlugin
import matlab.unittest.plugins.CodeCoveragePlugin
import matlab.unittest.plugins.codecoverage.ProfileReport
import matlab.unittest.plugins.codecoverage.CoverageR

runner = TestRunner.withNoPlugins; runner = TestRunner.withNoPlugins;


plugin = CodeCoveragePlugin.forFolder('myTests',
plugin...
= CodeCoveragePlugin.forFolder('myTests', ...
'Producing',ProfileReport); 'Producing',CoverageReport);
runner.addPlugin(plugin) runner.addPlugin(plugin)

To create a MATLAB Profiler Coverage Report without specifying a ProfileReport format, see
Determine Code Coverage Using the Profiler.

8-50
External Language Interfaces

External Language Interfaces

C++ Interface: MATLAB data type for C++ array and std::vector
MATLAB provides an interface, clib.array, which wraps C++ native arrays and std::vector
types. To create an array of C++ array objects, call the MATLAB clibArray function. To convert a
MATLAB array to a C++ array, call clibConvertArray. For more information, see MATLAB Object
For C++ Arrays.

For information about creating a MATLAB interface, see Build MATLAB Interface to C++ Library.

Compatibility Considerations
By default, beginning in R2020a, MATLAB returns a clib.array object instead of the equivalent
MATLAB array for primitive types.

To continue to treat a return argument as a MATLAB array, call


clibgen.generateLibraryDefinition or clibgen.buildInterface with the 'ReturnCArrays'
argument set to false.

To update your code to use clib arrays, note that when you rebuild the library the MATLAB type for
these output arguments changes to clib.array.libname.classname. Also, MATLAB
automatically defines more parameters. In general, you still need to provide SHAPE information.

C++ Interface: Supported data types


Functionality in a C++ shared library using these types is included in the MATLAB interface to the
library.

• std::shared_ptr
• Pointer and array data members.
• Double pointers (**) to custom classes used as function or method parameter types. Double
pointers to primitive types are not supported.

These types are equivalent to MATLAB char:

• wchar_t
• char16_t
• char32_t

These types are equivalent to MATLAB string:

• char *
• std::wstring
• std::u16string
• std::u32string

For more information, see MATLAB to C++ Data Type Mapping. To determine if it is possible to
publish an interface to your library, see Limitations to C/C++ Support.

8-51
R2020a

C++ Interface: Lifetime management of C++ objects


If a library creates an object, then the library is responsible for releasing the memory. Likewise, if
MATLAB creates the object, then MATLAB is responsible for releasing the memory. MATLAB lets you
control the lifetime management of objects by specifying 'ReleaseOnCall' and 'DeleteFcn'
arguments in the library definition file. For more information, see Lifetime Management of C++
Objects in MATLAB.

MATLAB Data Array: Support for N-D row-major memory layout


You can create an N-D matlab::data::Array object with row-major memory layout. Previously, the
createArrayFromBuffer function created row-major arrays only in 2-D. To create a
matlab::data::Array object with row-major memory layout, set the createArrayFromBuffer
argument memoryLayout to MemoryLayout::ROW_MAJOR. To determine the memory layout for an
existing matlab::data::Array object, call getMemoryLayout.

MATLAB COM Server: Register MATLAB without administrative


privileges
If you do not have an administrator account on a Microsoft Windows system or you do not start
MATLAB with administrative privileges, you can use the comserver function to register MATLAB as
a COM server for your user account. If you have an administrator account, then you also can call
comserver to register MATLAB for all users. For more information, see Register MATLAB as COM
Server. For general information about the MATLAB COM Automation server, see Calling MATLAB as
COM Automation Server.

Java interface: MATLAB support for OpenJDK™ 8 (Hot Spot)


As of R2020a, MATLAB supports OpenJDK 8 (Hot Spot) from https://adoptopenjdk.net/.

Compiler support changed for building MEX files and standalone


MATLAB engine and MAT-file applications
Support Compiler Platform
Added Intel Parallel Studio XE 2020 for C, C++, and Fortran Windows
Added Intel Parallel Studio XE 2020 for Fortran macOS
Added Apple Xcode 11.x macOS
Discontinued Intel Parallel Studio XE 2017 Windows

macOS

To ensure continued support for building your MEX files, consider upgrading to another supported
compiler. For an up-to-date list of supported compilers, see Supported and Compatible Compilers.

Functionality being removed or changed


createSoapMessage, callSoapService, and parseSoapResponse will be removed
Warns

8-52
External Language Interfaces

Consider using matlab.wsdl.createWSDLClient instead of the createSoapMessage,


callSoapService, and parseSoapResponse functions to communicate with Web services using
Simple Object Access Protocol (SOAP). There is no direct function replacement for the SOAP
functions, but when you create a WSDL interface, you have access to the Web service functionality.

createClassFromWsdl will be removed


Warns

The matlab.wsdl.createWSDLClient function replaces the createClassFromWsdl function to


communicate with Web services from MATLAB using Web Services Description Language (WSDL).
matlab.wsdl.createWSDLClient enables you to specify additional information needed to access
the WSDL document. For more information, see weboptions.

To get started using matlab.wsdl.createWSDLClient, follow these steps.

1 Download supported versions of the Java JDK and Apache CXF programs. For more information,
see Set Up WSDL Tools.
2 Set the paths to these programs:

matlab.wsdl.setWSDLToolPath('JDK',jdk,'CXF',cxf)

where jdk is the path to the JDK installation and cxf is the path to the CXF program.

To update your code, replace calls to createClassFromWsdl with calls to


matlab.wsdl.createWSDLClient. For example, for a Web service with this URL:
url = 'https://examplesite.com/samplewebservice';

replace this call to createClassFromWsdl:


createClassFromWsdl(strcat(url,'?WSDL'))

with:

matlab.wsdl.createWSDLClient(url)

Note matlab.wsdl.createWSDLClient does not support RPC-encoded WSDL documents.

8-53
R2020a

Hardware Support

MATLAB Support Package for Ryze Tello Drones: Control Ryze Tello
drone from MATLAB and acquire sensor and image data
The MATLAB Support Package for Ryze Tello Drones is available from release R2020a onwards.

The support package includes functions to pilot Ryze Tello and Ryze Tello EDU drones by sending
MATLAB commands to control its direction, speed, and orientation. You can also read flight
navigation data such as speed, height, and orientation, capture images, and stream live video into
MATLAB from the drone's first-person view (FPV) camera.

Support added for Raspberry Pi 4B model board


You can use the MATLAB Support Package for Raspberry Pi Hardware with the Raspberry Pi 4B
board.

Deploy deep learning applications on Raspberry Pi hardware


The MATLAB Support Package for Raspberry Pi Hardware now enables you to deploy deep learning
applications on the hardware. The deep learning applications continue to run on the Raspberry Pi
even if the hardware is disconnected from the computer. To support deployment, the Raspberry Pi
functions listed in Functions Supported for Deployment (MATLAB Support Package for Raspberry Pi
Hardware) are enhanced to generate C++ code. Like any MATLAB function, you can deploy the deep
learning application using these steps in Workflow to Deploy MATLAB Function on Raspberry Pi
(MATLAB Support Package for Raspberry Pi Hardware) with an additional step of creating a deep
learning configuration object and assigning it to the CoderConfig.DeepLearningConfig property
of Raspberry Pi before deployment.

For example, to deploy the deep learning application raspi_webcam_resnet.m:

1 Create a configuration object for the Raspberry Pi hardware and set the language of the
generated code to C++ using TargetLang.

t = targetHardware('Raspberry Pi');
t.CoderConfig.TargetLang = 'C++';
2 Create an arm-compute deep learning configuration object and assign it to the
DeepLearningConfig property of the Raspberry Pi configuration object.

dlcfg = coder.DeepLearningConfig('arm-compute')
dlcfg.ArmArchitecture = 'armv7';
t.CoderConfig.DeepLearningConfig = dlcfg;
3 Deploy the application on the Raspberry Pi hardware.

deploy(t,'raspi_webcam_resnet.m')

Read GPS Data from GPS Receiver Connected to Arduino Hardware


The MATLAB Support Package for Arduino Hardware enables you to read GPS data from the GPS
receiver connected to an Arduino hardware.

8-54
Hardware Support

Use BNO055 Sensor with Sensor Fusion and Tracking Toolbox, and
Navigation Toolbox to Estimate Orientation
You can read acceleration, angular velocity, and magnetic field up to 200Hz in the non-fusion mode of
the BNO055 IMU sensor connected to the Arduino hardware. To estimate orientation, you can use the
sensor with Sensor Fusion and Tracking Toolbox™, and Navigation Toolbox™.

Enable Code Generation of MATLAB Arduino Functions Inside a


MATLAB Function Block for I2C and SPI
In addition to the existing support of ADC, PWM, and Digital Read/Write, you can now generate code
for Arduino MATLAB functions inside a MATLAB function block for I2C and SPI.

Functionality being changed or removed


The i2cdev and spidev functions will be removed in R2020a
Warns

Use the device instead of i2cdev and spidev to connect to I2C or SPI devices on Arduino
hardware .

The property Pins of servo object will be removed in R2020a


Warns

Use the property Pin instead of Pins to get the pin number of the Arduino hardware and the
Adafruit® Motor Shield V2 for Arduino hardware to which the servo motor is connected. For more
information, see Connection to servo motor on Arduino and Connection to servo motor on Adafruit
Motor Shield V2 .

The class arduinoio.LibraryBase will be removed in R2020a


Warns

Use the class matlabshared.addon.LibraryBase instead of arduinoio.LibraryBase for


deriving Arduino add-on libraries.

MATLAB support for Adafruit Bluefruit EZ-Link Shield and Programmer will be removed in
R2020a
Warns

The support for Adafruit Bluefruit EZ-Link Shield and Programmer will be removed in R2020a.

8-55
9

R2019b

Version: 9.7

New Features

Bug Fixes

Compatibility Considerations
R2019b

Environment

Live Editor Tasks: Add interactive tasks to live scripts to explore


parameters and automatically generate code
Live Editor tasks are app-like interfaces that can be added to a live script to perform a specific set of
operations. Use tasks to reduce development time, errors, and time spent plotting. Tasks
automatically generate code that becomes part of your live script.

To add a task to a live script, go to the Live Editor tab, click Task , and select from the
available tasks. You also can type the name of the task in a live script code block. As you type, the
Live Editor displays possible matches, and you can select and insert the desired task.

For example, add the Smooth Data task to a live script to smooth noisy data.

9-2
Environment

For more information, see Add Interactive Tasks to a Live Script.

9-3
R2019b

Live Editor Output: Animate plots to show changes in data over time
You can include for-loop animations in the Live Editor to show changes in plotted data over time. For
example, this code animates a line growing as it accumulates 2,000 data points in the Live Editor. The
drawnow function displays the changes after each iteration through the loop.

h = animatedline;
axis([0 4*pi -1 1])
x = linspace(0,4*pi,2000);

for k = 1:length(x)
y = sin(x(k));
addpoints(h,x(k),y);
drawnow
end

Live Editor Output: Adjust the width of columns in tables


Adjust the width of table columns in the Live Editor by clicking and dragging the column border to
the desired width.

Live Editor Output: Scroll through and copy data in arrays such as cell
arrays, object arrays, and struct arrays
You can use scroll bars to explore data in cell arrays, object arrays, and struct arrays. You also can
scroll through data in string arrays, numeric arrays, categorical arrays, datetime arrays, duration
arrays, and calendarDuration arrays.

To copy individual data values in output, select a value, right-click it, and choose the Copy Selection
option.

9-4
Environment

Live Editor Export: Customize figure format as well as document


paper size, orientation, and margins when exporting
You can programmatically change the resolution and format of images when exporting to PDF and
LaTeX in the Live Editor using settings. For example, this code specifies the JPEG figure format and a
resolution of 1200 DPI when exporting in the Live Editor for the current session.

s = settings;
s.matlab.editor.export.FigureFormat.TemporaryValue = 'jpeg';
s.matlab.editor.export.FigureResolution.TemporaryValue = 1200;

You also can programmatically change the paper size, orientation, and margins when exporting to
PDF, Microsoft Word documents, and LaTeX in the Live Editor. For example, this code specifies the
Legal paper size and landscape page orientation when exporting in the Live Editor for the current
MATLAB session.
s.matlab.editor.export.pagesetup.PaperSize.TemporaryValue = 'Legal';
s.matlab.editor.export.pagesetup.Orientation.TemporaryValue = 'Landscape';

To change the figure format, document paper size, orientation, and margins for an individual export
document type, specify the setting for that individual document type. For example, this code specifies
a portrait page orientation when exporting to PDF documents in the Live Editor, and a landscape
page orientation when exporting to all other document types. Set the personal value instead of the
temporary value for the settings to ensure that the values persist across MATLAB sessions.
s.matlab.editor.export.pagesetup.pdf.Orientation.PersonalValue = 'Portrait';
s.matlab.editor.export.pagesetup.Orientation.PersonalValue = 'Landscape';

For more information, see matlab.editor Settings.

Live Editor Code: Duplicate one or more lines of code


You can reuse one or more lines of code in a live script by duplicating them. To duplicate selected
lines, right-click them and select Duplicate Line(s). You also can use the keyboard shortcut Ctrl
+Shift+C (or Cmd+Shift+C on macOS).

9-5
R2019b

Live Editor Code: Suppress Code Analyzer warning messages


To suppress Code Analyzer warnings for a single line in the Live Editor, right-click a warning and
select Suppress Message... > On This Line. To suppress the warning for the entire document,
select Suppress Message... > In This File.

Error messages cannot be suppressed.

Live Editor Debugging: Set breakpoints for anonymous functions


In the Live Editor, you can set breakpoints for anonymous functions. To add a breakpoint, click the
gray area to the left of an executable line that contains the anonymous function. MATLAB adds a
breakpoint to the line and a disabled breakpoint to the left of each anonymous function in the line.
Click the disabled breakpoint to enable it.

Live Editor Internationalization: Add non-English language such as


Chinese, Japanese, and Korean characters on Windows and macOS
Platforms
You can specify different input methods on Windows and macOS systems to add non-English
languages such as Chinese, Japanese, and Korean characters to code and text in the Live Editor.

Add-On Manager: Update MATLAB and other installed add-ons


You can update MATLAB and other installed add-ons to their latest version in the Add-On Manager. To
view and install available updates, on the Home tab, click Help > Check for Updates. The Add-On
Manager opens. Select the Update tab to view available updates. Click the Update button to the
right of an available update to install it. For more information, see Get and Manage Add-Ons.

Add-On Manager: Programmatically manage add-ons by name


Enable, disable, and uninstall add-ons programmatically by name using the
matlab.addons.enableAddon, matlab.addons.disableAddon, and
matlab.addons.uninstall functions.

For example, suppose that you have an add-on called Random File Name Creator installed on
your system. Disable Random File Name Creator by name.

matlab.addons.disableAddon("Random File Name Creator")


addons = matlab.addons.installedAddons

addons =

1×4 table

Name Version Enabled Identifier


___________________________ _________ _______ ______________________________________

"Random File Name Creator" "1.0" false "75442144-f751-4011-bm0e-32b6fb2f1433"

9-6
Environment

Settings: Create persistent settings for custom apps, toolboxes, and


across MATLAB sessions
You can add your own custom settings in MATLAB to store and access data programmatically across a
single or multiple MATLAB sessions.

For example, create the settings group mysettings and the setting MyWorkAddress inside it.
s = settings;
addGroup(s,'mysettings','Hidden',false);
addSetting(s.mysettings,'MyWorkAddress','Hidden',false);
s.mysettings.MyWorkAddress.PersonalValue = '3 Apple Hill Drive';

You can then use the setting value programmatically in your code.
fprintf("I work at %s.\n", s.mysettings.MyWorkAddress.ActiveValue)

I work at 3 Apple Hill Drive.

For more information, see Create Custom Settings. To create settings for custom toolboxes, see
Create Factory Settings for Toolboxes.

MATLAB Drive: Share folders and collaborate with others from


MATLAB
If you have MATLAB Drive Connector installed and actively syncing, you can share folders in your
MATLAB Drive directly from MATLAB. To share a folder, right-click the folder in the Current Folder
browser and select Share.

You can share folders with a view-only link, or invite individual collaborators and set their editing
permissions. Invitations can be accepted or declined. After a folder is shared, you can manage the
permissions of invited members, rescind invitations, or send additional invitations at any time.

For more information, see “Share Folders Using MATLAB Drive”.

MATLAB Drive: Upload folders from MATLAB to MATLAB Drive online


(October 2019)
The Upload button in the MATLAB desktop now lets you upload folders as well as individual files.
This same functionality can be accessed by using the right-click context menu when viewing MATLAB
Drive online.

For more about file and folder uploading and downloading, see “Add Files to MATLAB Drive”.

Functionality being removed or changed


Live editor animations enabled by default
Behavior change

Starting in R2019b, for-loop animations in the Live Editor are enabled by default. To disable
animations in the Live Editor, set the matlab.editor.AllowFigureAnimation setting to false:

s = settings;
s.matlab.editor.AllowFigureAnimation.PersonalValue = false;

9-7
R2019b

Language and Programming

size Function: Find lengths of multiple array dimensions at a time


You can now use a vector dimension argument to query multiple array dimension lengths at a time
with the size function. For example, sz = size(A,[1 3]) returns a 1-by-2 row vector containing
the lengths of dimensions 1 and 3 of the input array A.

matches Function: Determine if input strings are equal


You can determine if two input strings are equal. For more information, see matches.

Hexadecimal and Binary Numbers: Specify numbers using


hexadecimal and binary literals
You can write numbers using hexadecimal and binary notation. For example, you can write the
number 42 as A = 0x2A using the 0x prefix to indicate hexadecimal format. For more information,
see Hexadecimal and Binary Values.

Indexing: Use dot indexing into function calls


You can now use dot indexing to index into the result of a function call. MATLAB evaluates the
function and then applies the dot indexing operation to the result.

For example, this function creates a structure:

function out = createStruct(in)


out = struct("aField", in);
end

You can call this function and immediately access the structure field it creates:

createStruct(3).aField

For more information, see Indexing into Function Call Results.

System object authoring improvements: Property validation support


and simplified class inheritance
When you author System objects, you can now use property validation to restrict property values. For
information about property validation, see Validate Property Values.

The methods from the matlab.system.mixin.CustomIcon, matlab.system.mixin.Nondirect,


matlab.system.mixin.Propagates, and matlab.system.mixin.SampleTime mixin classes are
now directly included with matlab.System. You no longer need to inherit from these mixin classes
when authoring System objects.

9-8
Language and Programming

Function Input Arguments: Declare function input arguments to


restrict values
Function argument validation is a way to declare specific restrictions on function input arguments.
Using function argument validation, you can constrain the class, size, and other aspects of function
input values without writing code in the body of the function to perform these tests. For more
information, see Function Argument Validation.

namedargs2cell Function: Convert structure containing name-value


pairs to cell array
Convert a scalar structure array that contains name-value data into an interleaved cell array suitable
for passing to functions that accept name-value pair cell arrays. This function is typically used with
the name-value structure created using function argument validation. For more information, see
namedargs2cell.

delete, dir, isfile, isfolder, and what Functions: Access web-based


storage services like Amazon Web Services and Azure Blob Storage
You can now use the delete, dir, isfile, isfolder, and what functions to work with remote files
and folders. To access remote locations, you must specify the full path using a uniform resource
locator (URL). For example, check if a file exists on the specified path in Amazon S3 Cloud.
result = isfile('s3://bucketname/path_to_file/my_image.jpg')

For more information on setting up MATLAB to access your online storage service, see Work with
Remote Data.

Suggested Corrections: Correct errors with two new classes


In addition to the AppendArgumentsCorrection class, you can now provide a suggested fix using
the ReplaceIdentifierCorrection and ConvertToFunctionNotationCorrection classes.

• To suggest replacing an identifier in the function call where the exception was thrown, use the
ReplaceIdentifierCorrection class.
• To suggest the function notation equivalent of the dot notation expression from which the
exception was thrown, use the ConvertToFunctionNotationCorrection class.

error Function: Provide suggested fix for uncaught exception


You can now use the error function to provide a suggested fix when the thrown exception is not
caught. To use this functionality, specify the first argument of error as an object that suggests the
correction. For example, display a suggestion for missing arguments by specifying an
AppendArgumentsCorrection instance.
aac = matlab.lang.correction.AppendArgumentsCorrection(["'InitialCondition'","0"]);
error(acc,msgID,msgText)

Functionality being removed or changed


Program files larger than 128 MB or with high complexity produce error
Behavior change

9-9
R2019b

Starting in R2019b, program files larger than approximately 128 MB do not open or run. For files that
contain only code (for example, .m and .p files), this limit affects the file size. For files that store
more than just code (for example, .mlx files), it affects the size of the code. Running statements
larger than 128 MB, either directly in the Command Window or using the eval function, also is not
supported. In addition, code with high levels of complexity, such as a large number of deeply nested
if statements, is not supported.

Large program file or statement sizes could result in unpredictable behavior and often occurred when
using large portions of code (for example, over 500 lines) to define variables with constant values. To
decrease the size of program files, consider defining the variables and saving them in a data file (for
example, a MAT-file or .csv file). Then you can load the variables instead of executing code to
generate them. This adjustment not only decreases the file size of your program but also can increase
performance.

Change in rules for function precedence order


Behavior change

Starting in R2019b, MATLAB changes the rules for name resolution, impacting the precedence order
of variables, nested functions, local functions, and external functions. These rules are described in
Function Precedence Order. For information about the changes and tips for updating your code, see
Update Code for R2019b Changes to Function Precedence Order.

• Identifiers cannot be used for two purposes inside a function.


• Identifiers without explicit declarations might not be treated as variables.
• Variables cannot be implicitly shared between parent and nested functions.
• Change in precedence of compound name resolution.
• Anonymous functions can include resolved and unresolved identifiers.

The behavior of the import function has changed.

• Change in precedence of wildcard-based imports


• Fully qualified import functions cannot have the same name as nested functions
• Fully qualified imports shadow outer scope definitions of the same name.
• Error handling when import is not found.
• Nested functions inherit import statements from parent functions.

Some repetition arguments for repmat function now produce errors


Behavior change

Starting in R2019b, some repmat syntaxes involving nonscalar or empty repetition arguments will
produce an error. The following table describes how to update these syntaxes.

Errors Use Instead


repmat(A,r1,r2), where r1 and r2 are row repmat(A,[r1 r2])
vectors
repmat(A,empt), where empt is an empty array repmat(A,1)
repmat(A,empt1,empt2), where empt1 and repmat(A,1)
empt2 are empty arrays

9-10
Language and Programming

Errors Use Instead


repmat(A,n,empt), where n is an integer and repmat(A,[n 1])
empt is an empty array

Noninteger or complex dimension order arguments for permute function now produce
errors
Behavior change

Starting in R2019b, the permute syntax permute(A,dimorder) produces an error when dimorder
is a noninteger or complex value. Instead, specify real, positive integer values for dimorder.

Compare scalar enumerations in cell arrays to text using the strcmp function
Behavior change

strcmp now returns logical 0 or 1 for comparisons of scalar enumerations in cell arrays to text.
Previously, strcmp always returned 0.

For example, compare a matlab.lang.OnOffSwitchState enumeration in a cell and a character


vector.

enum = matlab.lang.OnOffSwitchState.off;
TF = strcmp({enum},'off')

TF =

logical

In previous releases, this comparison using strcmp returned 0.

You can also compare {enum} to a cell array of character vectors or to a string array.

TF = strcmp({enum},{'on','off'})

TF =

1×2 logical array

0 1

However, comparison to strings in cell arrays, such as strcmp({enum},{"off"}), always returns 0.


Cell arrays of string arrays are not recommended.

Behavior of nargin for functions that use function argument validation


Behavior change

If the function name input argument to nargin refers to a function that uses function argument
validation, then the returned value is the number of positional arguments on the function line. This
change in behavior can affect code that uses nargin with functions that are subsequently updated to
use the function argument validation feature. For more information, see nargin in Argument
Validation.

Dot-parenthesis syntax will not be allowed in validation function calls


Behavior change in future release

9-11
R2019b

Calling validation functions from properties or arguments blocks using dot-parenthesis syntax in
the function name will be disallowed in a future release. For example, this syntax will be invalid:
classdef MyClass
properties
A {a.('b').mustBePositive} % Dot-paren not allowed
end
end

Validation function must refer to the property being validated


Behavior change in future release

Property validation functions that do not refer to the property being validated will be disallowed in a
future release. For example, in this class definition, the input to the mustBePositive function is the
constant 10 instead of the property value.
classdef MyClass
properties
A {mustBePositive(10)} % Property not validated
end
end

To validate the property value, either pass the property name explicitly, or allow MATLAB to pass the
property implicitly:
classdef MyClass
properties
A {mustBePositive}
end
end

Function handles will not be allowed as inputs to property validation functions


Behavior change in future release

Passing function handles to property validation functions will be disallowed in a future release. If you
define a validation function that must use a function handle, then define the function handle in the
body of the validation function.

For example, it will be an error to pass the function handle @sin to the customValFcn function:
classdef MyClass
properties
A {customValFcn(A,@sin)} % Will result in error
end
end

function customValFcn(A,fh)
% function body
end

Instead, define the function handle in the custom validation function.


classdef MyClass
properties
A {customValFcn(A)}
end
end

9-12
Language and Programming

function customValFcn(A)
fh = @sin;
% function body
end

9-13
R2019b

Data Analysis

Live Editor Tasks: Interactively preprocess data and generate code


Use Live Editor tasks to join tables; smooth data; handle outliers and missing data; remove trends;
and find local minima, local maxima, and change points. Interactively explore the effects of your
changes using generated plots. The tasks also automatically generate code that becomes part of your
live script.

MATLAB now offers seven data preprocessing tasks:

• Join Tables — Combine two tables using key variables.


• Smooth Data — Smooth noisy data.
• Clean Outlier Data — Find, fill, or remove outliers.
• Clean Missing Data — Find, fill, or remove missing data.
• Remove Trends — Remove polynomial trend from data.
• Find Local Extrema — Find local maxima and minima.
• Find Change Points — Find abrupt changes in data.

To open tasks in the Live Editor, use the Task menu on the Live Editor tab. For more information,
see Add Interactive Tasks to a Live Script.

groupfilter Function: Filter data in a table, timetable, or matrix by


group
The groupfilter function allows you to filter rows of data by group according to a specified
filtering method. For example, given a table T, group by variable Var1 and return only the rows of T
whose group has more than one element.

>> T = table(["A" "B" "C" "A" "A"]',[1 2 3 4 5]')

T =

5×2 table

Var1 Var2
____ ____

"A" 1
"B" 2
"C" 3
"A" 4
"A" 5

>> G = groupfilter(T,'Var1',@(x) numel(x) > 1)

G =

3×2 table

Var1 Var2
____ ____

9-14
Data Analysis

"A" 1
"A" 4
"A" 5

datetime Data Type: Detect formats with fractional seconds when


converting text that represents dates and times
The datetime function allows you to convert text that includes fractional seconds without specifying
the 'InputFormat' name-value pair argument. For example, given text representing a date and
time that includes milliseconds, convert the text to a datetime value.
d = datetime('2019-07-01 12:34:56.123')

d =

datetime

01-Jul-2019 12:34:56

While the fractional seconds are detected, the default format for displaying values does not include
fractional seconds. To display the fractional seconds, add '.SSS' to the Format property of d.
d.Format = 'dd-MMM-uuuu HH:mm:ss.SSS'

d =

datetime

01-Jul-2019 12:34:56.123

For more information, see the Format property of datetime.

table and timetable Data Types: Variable names can have any
characters, including spaces and non-ASCII characters
Starting in R2019b, the names of variables in tables and timetables can have any Unicode characters,
including spaces and non-ASCII characters. Previously, table and timetable variable names had to be
valid MATLAB identifiers. For more information, see table, timetable, or Access Data in Tables.

This feature has several implications.

• While table and timetable variable names can have any characters, the table2struct and
summary functions do modify variable names that are invalid when you use them as structure field
names. The names of fields in a structure must be valid MATLAB identifiers.

To determine if a name is a valid identifier, use the isvarname function.


• You can access any table or timetable variable using dot notation. However, if a variable name is
not a valid MATLAB identifier, then you must specify the name as an expression within
parentheses following the dot. The expression can be a variable name enclosed in quotation
marks, or a function that returns a character vector or string scalar.

For example, if the table T has variables named 'Age' and 'Blood Pressure', then you can use
dot notation to access the variables. You can use both of the following syntaxes to access Age
because it is a valid MATLAB identifier.

9-15
R2019b

T.Age
T.('Age')

However, to access the variable named 'Blood Pressure' using dot notation, you must use
parentheses because the name is not a valid MATLAB identifier.

T.('Blood Pressure')

Compatibility Considerations
• Starting in R2019b, table and timetable variable names with leading or trailing whitespace
characters are not modified.

In previous releases, leading and trailing whitespace characters were deleted from variable names
when you specified them using the 'VariableNames' name-value pair argument, or assigned
them to the VariableNames property.

This change in behavior affects the array2table, array2timetable, cell2table, table, and
timetable functions, and the VariableNames property of tables and timetables. To remove such
characters manually, first use the strtrim function on the names, then assign them as variable
names to the table or timetable.
• Starting in R2019b, MATLAB raises an error if you assign a table variable name that matches a
dimension name, or a dimension name that matches a variable name. In previous releases,
MATLAB raised a warning and modified the names so they were unique.

tall Arrays: Operate on tall arrays with more functions, including


setdiff, xcorr, and outerjoin
The functions listed in this table now support tall arrays as inputs. For a complete list of supported
functions, type methods tall. For more information on usage and limitations, see the Extended
Capabilities section at the bottom of each reference page.

isregular vartype
outerjoin xcorr
setdiff xcov
setxor

In addition, some functions have removed limitations with tall arrays.

Functions Added Support


min and max min and max now fully support tall arrays.

Previously, you could not specify multiple outputs.


conv, conv2, and convn conv, conv2, and convn now support more
mixtures of tall arrays and in-memory arrays in
the inputs.

Previously, the second input B could not be a tall


array.

9-16
Data Analysis

Functions Added Support


innerjoin innerjoin now fully supports tall arrays.

Previously, you could only specify one output


argument, and one of the inputs was required to
be an in-memory array.
intersect intersect now allows both inputs to be tall
arrays.

Previously, one of the inputs was required to be


an in-memory array.

tall Arrays: Avoid running out of memory due to temporary copies of


data
If you convert an in-memory array A into a tall array using T = tall(A), then MATLAB avoids
creating copies of the underlying data when you perform subsequent operations on T, which relaxes
the memory requirements of many operations. This approach is useful if, for example, you have 8 GB
of RAM and perform an operation on a 5 GB array that normally requires a temporary copy of the
data.

Previously, the syntax tall(A) for an in-memory array A did not avoid creating temporary copies of
data, and was bound by the same memory requirements as in-memory arrays.

9-17
R2019b

Data Import and Export

detectImportOptions Function: Specify the type of import options for


delimited or fixed-width text files
When detecting import options for a text file, the detectImportOptions function now enables you
to specify the type of the text file as 'delimitedtext' or 'fixedwidth'. For more information,
see detectImportOptions.

table and timetable Data Types: Read and write tabular data that has
variable names containing any characters, including spaces and non-
ASCII characters
Starting in R2019b, you can read and write tables and timetables containing variable names that
have any Unicode characters, including spaces and non-ASCII characters. Previously, table and
timetable variable names had to be valid MATLAB identifiers.

To read tabular data that contains arbitrary variable names, such as variable names with spaces and
non-ASCII characters, set the PreserveVariableNames parameter to true.

T = readtable('myFile.xls','PreserveVariableNames',true)

The following functions support reading and writing of tabular data containing variable names that
contain any characters:

• Import Tool, readtable, readtimetable, and parquetread


• detectImportOptions, spreadsheetImportOptions, delimitedTextImportOptions, and
fixedWidthImportOptions
• tabularTextDatastore, spreadsheetDatastore, and parquetDatastore
• writetable, writetimetable, and parquetwrite
• save and load

If you save a table or timetable to a MAT-file (using the save function), then the MAT-file contains
both original and modified names for any variables whose names are not valid identifiers. If you load
the MAT-file into R2019b or later (using the load function), then the table or timetable uses original
variable names. If you load it into R2019a or earlier, then the table or timetable uses the modified
variable names.

For more information, see table, timetable, or Access Data in Tables.

sheetnames Function: Get names of worksheets from spreadsheet file


Use the sheetnames function to get the names of all worksheets from a spreadsheet file. For more
information, see sheetnames.

VideoReader Object: Read frames in videos using frame index or time


The VideoReader object supports interchangeable access to video frames using frame index or time.
Therefore, you can now use read and readFrame interchangeably.

9-18
Data Import and Export

Previously, you could use only one type of access at a time. Attempting to read frames
interchangeably using read and readFrame resulted in an error. For example, the following code
would result in an error.

vidObj = VideoReader('xylophone.mp4');
frame20 = read(vidObj,20); % read using frame index
frame21 = readFrame(vidObj) % read next frame using CurrentTime

Cannot call 'READFRAME' method after querying the


NUMBEROFFRAMES property or using the READ method.
Recreate the object to use 'READFRAME' method.

However, starting in R2019b, you can use all the methods and properties of the VideoReader object
interchangeably between accessing frames using frame indices and accessing frames using time. For
example, create a VideoReader object and read the 20th frame using the read method. Next, use
the readFrame method to get the 21st frame.

vidObj = VideoReader('xylophone.mp4');
frame20 = read(vidObj,20);
frame21 = readFrame(vidObj);
whos frame20 frame21

Name Size Bytes Class Attributes

frame20 240x320x3 230400 uint8


frame21 240x320x3 230400 uint8

For more information, see VideoReader.

VideoReader Object: Improved performance in generated code with


row-major layout
For large video files, the generated code for the VideoReader object with a row-major layout option
shows improved performance. For example, the timingTest function shows about a 4x speed-up on
a H.264 video file with a resolution of 1280x720.

function [t, data] = timingTest(fileName)


vidObj = VideoReader(fileName);
data = cell(20,1);
tic;
for cnt = 1:20
data{cnt} = readFrame(vidObj);
end
t = toc;
end

Generate code for the timingTest function with the row-major flag. The codegen command creates
a function timingTest_mex with the C and C++ generated code.

codegen timingTest -args {coder.typeof('', [1 inf])} -rowmajor

For a H.264 video file with a resolution of 1280x720, the execution times are:

R2019a: 4.04s

R2019b: 0.95s

9-19
R2019b

The code was timed on a Windows 10, Intel Xeon® CPU W-2133 @ 3.6 GHz test system by calling the
function timingTest_mex. The higher the video file resolution (measured by frame size), the greater
the performance improvement becomes.

Import Tool: Generate simpler code when importing from fixed-width


text files
Import Tool now operates consistently across different platforms and generates code that is easy to
read when importing fixed-width text files. For example, the generated code contains readtable and
FixedWidthImportOptions, which makes the code simpler to read and use. For more information,
see Read Text File Data Using Import Tool.

save Function: Save workspace variables to a MAT-file version 7


without compression
Previously, the save command, when saving workspace variables to a version 7 MAT-file, used
compression as the default (and the only) option. Now, save supports the '-nocompression' option
for MAT-file version 7.

By default, saving a variable myVariable compresses the data and saves it to a version 7 MAT-file.
The -v7 flag is optional.

save myFile.mat myVariable –v7

To save myVariable without compression, use:

save myFile.mat myVariable –v7 –nocompression

For more information, see save.

xmlread Function: Prevent reading of XML files that contain DOCTYPE


declarations
You can prevent reading XML files that contain DOCTYPE declarations by setting the
'AllowDoctype' name-value pair to false. For more information, see the xmlread reference page.

imread Function: Supports reading specified images from PGM, PBM,


or PPM file formats
The imread function supports reading specified images from multi-image PGM, PBM, or PPM file
formats. For more information, see the imread reference page.

Scientific File Format Libraries: CFITSIO Library upgraded to version


3.450
The CFITSIO library is upgraded to version 3.450.

9-20
Data Import and Export

Scientific File Format Libraries: LibTIFF Library upgraded to version


4.0.10
The LibTIFF library is upgraded to version 4.0.10.

RESTful Functions: Support for authentication


The RESTful web services functions webread, websave, and webwrite also support Digest
authentication. For more information, see the weboptions 'Username' argument.

For the list of supported authentications for RESTful functions, see Server Authentication.

Compatibility Considerations
The RESTful functions webread, webwrite, and websave now adhere more closely to the Internet
Engineering Task Force (IETF®) document RFC 7617 for Basic authentication. As a result, MATLAB
might error when a RESTful function communicates with a server that proactively expects Basic
authentication but does not return a 401 challenge response.

To update your code, see How do I preemptively include a Basic Authentication header when working
with "webread"/"webwrite"/"websave" in MATLAB R2019b?

tcpclient, read, and write Functions: Generate C and C++ code


The tcpclient, read, and write functions support C and C++ code generation using MATLAB
Coder.

Bluetooth Low Energy Interface: Support for scanning and interacting


with peripheral devices
You can use MATLAB commands to perform the following operations:

• Scan for nearby peripheral devices and view advertising data using the blelist function
• Connect to peripheral devices using the ble function
• Access device characteristics and descriptors using the characteristic and descriptor
functions
• Read device characteristic data and descriptor data using the read function
• Write to device characteristics and descriptors using the write function
• Enable and disable notification or indication for a characteristic using the subscribe and
unsubscribe functions

For more information, see Bluetooth Low Energy Communication.

Serial Port Devices: New functions and properties

The serial port interface has a new set of functions and properties. The existing functionality still
runs, but new function names and properties are recommended. The new interface has improved
performance.

9-21
R2019b

Get started with the new interface by viewing a list of all serial ports on your computer using
serialportlist.

list = serialportlist

list =

1×4 string array

"COM1" "COM3" "COM4" "COM8"

Then, create a serialport object, write data to the device, and read from it.

s = serialport("COM8",115200);
write(s,1:5,"uint32")
read(s,5,"uint32");

For more information, see Serial Port Devices.

Compatibility Considerations
For more information about updating your code to use the recommended functionality, see Transition
Your Code to serialport Interface.

Functionality being removed or changed


Import Tool does not support importing text data as cell array of character vectors
Behavior change

Previously, Import Tool provided an option to import text data as a cell array of character vectors.
Starting in R2019b, Import Tool does not support this. Instead, the Import Tool app imports text
data as string arrays.

To preserve the previous behavior, convert the imported text data to a cell array of character vectors
using the cellstr function.

UseExcel parameter for spreadsheets


Behavior change

The default setting for UseExcel on Windows systems with Excel installed is false.

The UseExcel parameter appears on these spreadsheet functions: readtable, readtimetable,


readmatrix, readcell, readvars, writetable, writetimetable, writematrix, and
writecell.

To preserve the previous behavior, update calls to these functions to specify the UseExcel parameter
as true. For example, for the readtable function, update your code as follows.

T = readtable(filename,'UseExcel',true)

xlsfinfo function is not recommended


Still runs

9-22
Data Import and Export

The xlsfinfo function is not recommended. Use the function sheetnames instead. There are no
plans to remove xlsfinfo at this time. The sheetnames function has these advantages over the
xlsfinfo function:

• Support for sheet names containing non-ASCII characters


• Better cross-platform support and performance
• Ability to work with remotely stored data

This table shows a typical use of xlsfinfo and how to update your code to use sheetnames.

Not Recommended Recommended


[~,sheets] = xlsfinfo('myData.xls') sheets = sheetnames('myData.xls')

NumberOfFrames property of the VideoReader object is not recommended


Still runs

The NumberOfFrames property of the VideoReader object is not recommended. Use the property
NumFrames instead. Update all instances of NumberOfFrames with NumFrames. There are no plans
to remove the NumberOfFrames parameter at this time.

Array of VideoReader objects is not supported

Creating an array of VideoReader objects is not supported. Update your code to remove arrays of
VideoReader objects. For example, the following code returns an error.
v = VideoReader('xylophone.mp4');
v(end+1) = VideoReader('xylophone.mpg');

Array formation and parentheses-style indexing


with objects of class 'VideoReader' is not allowed.
Use objects of class 'VideoReader' only as scalars
or use a cell array.

Tiff object for writing certain TIFF files

Writing TIFF images with certain combinations of photometric configuration and the number of
samples per pixel is not recommended. The value of SamplesPerPixel must be equal to the sum of
Photometric color channels and the ExtraSamples specified in the Tiff object. For more
information, see Tiff and write.

imwrite function does not support writing of indexed PNG files that have insufficient
colormap entries

Starting in R2019b, for writing indexed PNG files, you must specify a colormap with enough entries
to interpret the image correctly. For more information, see the imwrite reference page.

imfinfo function returns information on multiple images from PGM, PBM, and PPM files
Behavior change

Previously, for the PGM, PBM, and PPM file formats, the imfinfo function returned a single 1-by-1
structure. The structure contained information about only the first image, even if the file contained
multiple images in it.

9-23
R2019b

Starting in R2019b, if the PGM, PBM, and PPM files have multiple images, then imfinfo returns a
structure array containing information on multiple images in the file. For instance, for a PGM file
containing M images, imfinfo returns a 1-by-M structure array containing information corresponding
to all the images in the file.

This table shows how to update your code to get the Height (or any other property) of the first image
of a multi-image PBM, PGM, or PPM file.

Not Recommended Recommended


info = imfinfo('MultiImgFile.pgm') info = imfinfo('MultiImgFile.pgm')
info.Height info(1).Height

For more information, see imfinfo.

web Function
Behavior change

The web function now opens external sites using your system browser by default. Previously, the web
function opened external sites using the MATLAB browser. Using the system browser is
recommended when opening external sites.

To use the MATLAB browser as the default browser for external sites, go to the Home tab, and in the
Environment section, click Preferences. Select MATLAB > Web and in the System Web browser
section, clear the Use system web browser when opening links to external sites
(recommended) option.

Web services use system certificates


Behavior change

The default value for the CertificateFilename option in the weboptions function and the
matlab.net.http.HTTPOptions.CertificateFilename property is 'default'. If the value is
'default', then MATLAB uses system certificates.

Previously by default, MATLAB used the PEM certificate file that ships with MATLAB.

seriallist function is not recommended


Still runs

seriallist is not recommended. Use serialportlist instead. See Transition Your Code to
serialport Interface for more information about using the recommended functionality.

serial function is not recommended


Still runs

serial and its object properties are not recommended. Use serialport and its properties instead.

This example shows how to connect to a serial port device using the recommended functionality.

Functionality Use Instead


s = serial("COM1"); s = serialport("COM1",115200);
s.BaudRate = 115200;
fopen(s)

9-24
Data Import and Export

See Transition Your Code to serialport Interface for more information about using the
recommended functionality.

9-25
R2019b

Mathematics

makima Function: Perform modified Akima cubic Hermite interpolation


The makima function performs modified Akima cubic Hermite interpolation, similar to the 'makima'
interpolation method of griddedInterpolant, interp1, interp2, interp3, and interpn. The
modified Akima cubic Hermite interpolation method has these properties:

• It is C1 continuous.
• It produces fewer undulations than spline, but the result is not as aggressively flattened as
pchip.
• Unlike pchip, it supports N-D arrays.
• Unlike spline, it does not produce overshoots.

9-26
Graphics

Graphics

Chart Container Class: Develop your own class of charts


Define your own class of charts by creating a subclass of the
matlab.graphics.chartcontainer.ChartContainer base class. If you write scripts or
functions for creating specialized visualizations and share them with others, consider creating a class
implementation. Creating a class enables you to:

• Provide a convenient interface for your users — When users want to customize an aspect of your
chart, they can set a property rather than having to modify and rerun your graphics code. Users
can modify properties at the command line or inspect them in the Property Inspector.
• Encapsulate algorithms and primitive graphics objects — You implement methods that perform
calculations and manage the underlying graphics objects. Organizing your code in this way allows
you to hide implementation details from users.

The ChartContainer base class supports charts that have a single Cartesian axes. When you define
a chart that derives from this base class, instances of your chart are members of the graphics object
hierarchy. As a result, your charts are compatible with many aspects of the graphics system. For
example, the gca and findobj functions can return instances of your chart. For more information,
see Chart Development Overview.

tiledlayout and nexttile Functions: Create configurable layouts of


plots in a figure
Use the tiledlayout and nexttile functions to lay out a tiling of multiple plots within a figure.
The configuration options include:

• Control over the spacing between the plots and around the edges of the layout
• An option for a shared title at the top of the layout
• Options for shared x- and y-axis labels
• An option for displaying a shared axes toolbar
• An option to control whether the tiling has a fixed size or variable size that can reflow

9-27
R2019b

colororder Function: Control the colors in plots


Control the color scheme of your plots by calling the colororder function. When you change the
color scheme using this function, the change has an immediate effect on your existing plots. If you
call the colororder function for an empty figure, the new color scheme persists in the figure when
you call a plotting function.

Bar Charts: Create bar charts with improvements for stacking and
locating the tips of bars
The bar and barh functions have these improvements:

• Stacked groups of bars display negative bars below zero, rather than overlapping the bars.
• You can locate the tips of bars by getting the values of the XEndPoints and YEndPoints
properties on the Bar object. The locations are useful for adding labels to the tips of bars.
• Both functions now accept more combinations of scalar, vector, and matrix inputs.

Data Tips: Create and customize data tips


Create data tips on objects with a DataTipTemplate property using the datatip function. You can
create a data tip by specifying the exact coordinates of the data point, the approximate coordinates of
the data point, or the index of the data point within the plotted data set. Create a data tip between
plotted data points by setting the SnapToDataVertex property to 'off'.

In the Live Editor, generate code for interactively pinned data tips by clicking the Update Code
button. This generated code recreates the data tip the next time you run the live script.

Customize the content of data tips on additional charts, including Contour, Patch, Quiver, Bar,
and Image objects with a DataTipTemplate property. For more information, see Create Custom
Data Tips.

9-28
Graphics

dataTipInteraction Function: Pin data tips at cursor location


Create data tip interactions that pin data tips to the cursor location, rather than the nearest data
point, by setting the SnapToDataVertex property of the data tip interaction object to 'off':

For more about customizing axes interactions, see Control Chart Interactivity.

Axes Toolbar: Save or copy contents of axes as image

To save or copy the contents of a set of axes or a tiled chart layout, hover over the Export icon
and select an option from the drop-down menu. The available options depend on the content of the
axes.


Save to an image or PDF file by selecting Save As .

Copy to the clipboard as a PNG image by selecting Copy as Image .

Copy to the clipboard as a vector graphic for PDFs by selecting Copy as Vector .

When you create a custom toolbar using the axtoolbar function, include a drop-down menu with
save and copy options by specifying the buttons argument as 'export'.

parallelplot Function: Zoom, pan, and rearrange coordinates


interactively
The parallel coordinates plot has new options for interacting with data:

• Zoom — Use the scroll wheel to zoom.


• Pan — Click and drag the plot to pan.
• Rearrange coordinates — Click and drag a coordinate tick label to move the corresponding
coordinate ruler to a different position.

Property Inspector: Update axis tick values and labels using clipboard
data
You can update the tick values and labels that appear along an axis by copying and pasting data (for
example, from a spreadsheet) into the property inspector. To paste copied data, open the property
inspector and navigate to the ticks property that you want to edit. Then, open the drop-down menu by
clicking and select Paste.

9-29
R2019b

Image Interpolation: Select an interpolation method for displaying


images
Display images using either nearest neighbor or bilinear interpolation. MATLAB uses interpolation
when it displays a scaled or rotated version of an image.

When you call the image, imagesc, or imshow functions, specify the Interpolation property
name-value pair with either 'nearest' or 'bilinear' as the value. All images use 'nearest' by
default.

For example, this code displays an image using the imagesc function with bilinear interpolation:

I = imread('peppers.png');
imagesc(I,'Interpolation','bilinear')

legend Function: Create unlimited legend entries and specify


categorical arrays
The legend function has these improvements:

• The legend can display an unlimited number of entries when you specify the subset argument. In
previous releases, legends display up to 50 entries only.
• You can specify label values as categorical arrays in addition to cell arrays and string arrays.

pcolor Function: Specify categorical, datetime, and duration data


The pcolor function now accepts categorical, datetime, and duration arrays for X and Y.

Geographic Plots: Plot data on high-zoom-level basemaps


Plot data on high-zoom-level basemaps hosted by Esri. For more information about Esri, see https://
www.esri.com. Specify a basemap using the geobasemap function or by setting the Basemap
property of the GeographicAxes or GeographicBubbleChart object.

9-30
Graphics

'streets-light' 'satellite'

Map designed to Full global basemap


provide geographic composed of high-
context while resolution satellite
highlighting user data imagery.
on a light background.
Hosted by Esri.
Hosted by Esri.

'streets-dark' 'topographic'

Map designed to General-purpose map


provide geographic with styling to depict
context while topographic features.
highlighting user data
on a dark background. Hosted by Esri.

Hosted by Esri.

'streets'

General-purpose road
map that emphasizes
accurate, legible styling
of roads and transit
networks.

Hosted by Esri.

Geographic Plots: Create plots with improved basemap appearance


Starting in R2018b, basemaps within geographic plots have an improved visual appearance at
noninteger zoom levels. For example, the ZoomLevel property of these geographic bubble charts is
4.995.

9-31
R2019b

Geographic Axes: Display animations using comet or animatedline


Display animations on geographic axes using comet or animatedline. For more information, see
Line Animations.

Geographic Bubble Charts: Create charts with improved layout


Geographic bubble charts have an improved visual appearance, including use of figure space and
placement of ticks and tick labels.

When you resize a geographic bubble chart, font sizes and spacing between elements in the chart
automatically adjust to provide the best possible presentation for the new size. Changing the
FontSize property of a geographic bubble chart disables the automatic resizing of the fonts.

Functionality being removed or changed


Changing ColorOrder or LineStyleOrder on the axes affects existing plots immediately
Behavior change

If you change the axes ColorOrder or LineStyleOrder properties after plotting into the axes, the
colors and line styles in your plot change immediately. In previous releases, the new colors and line
styles affect only subsequent plots, not the existing plots.

For example, this code plots two lines before changing the value of the ColorOrder property. In
R2019a and previous releases, the colors of the two lines do not change when you change the
ColorOrder property.
plot([0 1],[1 0])
hold on
plot([0 1],[2 0])
ax = gca;
ax.ColorOrder = [1 0 0; 0 1 0];

9-32
Graphics

Starting in R2019b, the lines change immediately to use the new ColorOrder or LineStyleOrder
property values. If you want to prevent the change, set either the axes LineStyleOrderIndex or
ColorOrderIndex property to any value (such as its current value) before changing the
ColorOrder or LineStyleOrder property.

plot([0 1],[1 0])


hold on
plot([0 1],[2 0])
ax = gca;

% Preserve R2019a behavior


ax.ColorOrderIndex = ax.ColorOrderIndex;

ax.ColorOrder = [1 0 0; 0 1 0];

Indexing scheme for ColorOrder and LineStyleOrder might change plot colors and line
styles
Behavior change

In R2019a and previous releases, plots that visualize multiple sets of data rely on an indexing scheme
to select the colors and line styles. The indexing scheme generally works well, but it does not allow
you to change the colors and line styles in a plot after you create it.

Starting in R2019b, there is a new indexing scheme that enables you to change the colors and line
styles of existing plots. MATLAB always applies this indexing scheme to objects such as Line,
Scatter, and Bar. As a result, your code might produce plots that cycle through the colors and line
styles differently than in previous releases.

One example of the new behavior is when you create a line with a specific color, and then create
another line without specifying a color. In the following code, the first call to the plot function
includes a third argument that specifies the color as red. The second call to the plot function does
not specify a color. In R2019a, the first line is red, and the second line is blue.

% Plot two lines


hold on
plot([0 1],[1 0],'red')
plot([0 1],[2 0])

If you run the preceding code in R2019b, the first line is red and the second line is orange. To
preserve the original color, set either the axes LineStyleOrderIndex or ColorOrderIndex
property to any value (such as its current value) before plotting into the axes.

% Preserve R2019a behavior


ax = gca;
ax.ColorOrderIndex = ax.ColorOrderIndex;

% Plot two lines


hold on
plot([0 1],[1 0],'red')
plot([0 1],[2 0])

Predefined colormaps have 256 colors by default


Behavior change

The predefined colormaps, such as parula, jet, and winter, now have 256 colors by default.

9-33
R2019b

If you have code that depends on a predefined colormap having 64 colors, specify the number of
colors when you set the colormap for the figure, axes, or chart. For example,
colormap(parula(64)) sets the figure's colormap to the 64-color parula colormap.

Alternatively, you can change the default colormap for all figures within your MATLAB session:

set(groot,'defaultFigureColormap',parula(64))

Pie charts display zero values


Behavior change

When you call the pie or pie3 function and specify data that contains zero values, your pie chart
shows the zero values and corresponding labels. If you call either function with an output argument,
the output includes objects for each zero value.

In previous releases, the functions omit the zero values from the chart and do not return any objects
that correspond to those values. If you do not want to display zero values or return the corresponding
objects, then remove the zeros from your data.

Using the axis function to set axes limits no longer changes the view of the plot box
Behavior change

When you call the axis function to set limits, the plot box no longer changes its view in these
situations:

• When the plot box is in a 2-D view, and you pass a six-element vector to the axis function. To
preserve the behavior of previous releases, call view(3) after calling the axis function.
• When the plot box is in a 3-D view, and you pass a four-element vector to the axis function. To
preserve the behavior of previous releases, call view(2) after calling the axis function.

Default basemap for geographic plots is now 'streets-light'


Behavior change

Starting in R2019b, the default basemap for GeographicAxes and GeographicBubbleChart


objects is 'streets-light'. The 'streets-light' basemap requires Internet access.

In previous releases, the default basemap was 'darkwater'. This basemap is included with MATLAB
and does not require Internet access.

If you do not have reliable access to the Internet, you can use the 'darkwater' basemap or
download a selection of basemaps onto your local system using the Add-On Explorer. For more
information, see Access Basemaps in MATLAB.

Turning on interaction modes disables mouse interactions for geographic bubble charts
Behavior change

Starting in R2019b, turning on an interaction mode in a figure disables mouse interactions for
geographic bubble charts in the figure. For example, if you turn on zoom mode using the zoom
function, then you can no longer use the mouse to zoom or pan within the geographic bubble chart.
Other interaction modes include pan, rotate, data cursor, or brush mode.

To zoom or pan within a geographic bubble chart, turn off interaction modes within the figure and
zoom or pan using the built-in mouse interactions.

9-34
Graphics

Geographic bubble charts display tick labels using seconds


Behavior change

Starting in R2019b, the tick label format for geographic bubble charts is degrees, minutes, and
decimal seconds (DMS) rather than degrees and decimal minutes (DM).

9-35
R2019b

App Building

uistyle Function: Create styles for rows, columns, or cells in a table UI


component
You can create different styles for specific rows, columns, or cells in a table UI component using the
uistyle and addStyle functions. For example, you can make the cells in a specific column red with
italic font. To retrieve styles that have been applied, get the StyleConfigurations property of the
Table object. To remove a style from a table UI component, use the removeStyle function.

Cell styles in table UI components are supported only in App Designer apps and in figures created
with the uifigure function.

uigridlayout Function: Configure grid rows and columns to adjust


automatically to fit components
Grid layouts can automatically adjust to the minimum size needed to fit the components that are in it.
To configure grid rows and columns to fit components dynamically, specify 'fit' as the value of the
RowHeight or ColumnWidth properties for specific rows and columns in the GridLayout object.
For example, setting 'RowHeight' to {'fit',50,'1x'} specifies that the height of the first row is
tightly fit around the components, the second row is fixed at 50 pixels, and the third row uses the
remaining vertical space.

This feature is especially useful when you are creating rows and columns of text-based components
because when you use 'fit', you don't have to know how tall or wide to make the rows and columns
of the grid layout manager. The 'fit' option for row height and column width is also useful if your
app is translated to another language or runs on different platforms.

The uigridlayout function is supported only in App Designer apps and in figures created with the
uifigure function.

uitable Function: Sort table UI components interactively when using


logical, numeric, string, or cell arrays
You can interactively sort table UI components when the Data property contains logical data,
numeric data, string data, or cell array data. To sort table UI components that contain these data
types, set the ColumnSortable property of the Table object. To update visualizations based on how
a table UI component was sorted, also use the DisplayData property and a
DisplayDataChangedFcn callback function.

Sortable columns in table UI components are supported only in App Designer apps and in figures
created with the uifigure function.

uihtml Function: Embed HTML, JavaScript, or CSS content in apps and


on the App Designer canvas
To embed HTML, JavaScript, or CSS in your app, call the uihtml function or, in App Designer, drag
an HTML UI component from the Component Library onto the canvas.

9-36
App Building

HTML UI components are supported only in App Designer apps and in figures created with the
uifigure function.

App Designer: Convert components in a UI figure or container from


pixel-based positioning to a grid layout manager
You can convert the children of a UI figure or container from pixel-based positioning to being
positioned by a grid layout manager. To use a grid layout manager where you were previously using
pixel-based positioning, drag a grid layout from the Component Library onto the canvas or into an
existing container component, like a panel. Alternatively, right-click the canvas or container
component and select Apply Grid Layout.

The grid layout manager automatically creates rows and columns to accommodate the components,
and preserves their approximate positions. When you add a grid layout, the component hierarchy
updates in the Component Browser.

App Designer: Convert an existing app into an auto-reflowing app

To convert an existing app into an auto-reflowing app, expand the Convert drop-down menu in
the Canvas tab, and select 2-Panel App with Auto-Reflow or 3-Panel App with Auto-Reflow.

Auto-reflowing apps automatically resize and reflow content based on screen size, screen orientation,
and platform. Use apps with auto-reflow if you expect to run or share your apps across multiple
environments or desktop resolutions. For more details, see Apps with Auto-Reflow.

App Designer: Suppress Code Analyzer warning messages


In the App Designer Code View editor, you can suppress Code Analyzer warnings for a single line or
for the entire app file. To suppress warnings, right-click a warning and, from the context menu,
select:

• Suppress Message... > On This Line


• Suppress Message... > In This File

For example,

Error messages, however, cannot be suppressed.

9-37
R2019b

App Designer: Open App Designer from the MATLAB toolstrip

To open App Designer from the MATLAB toolstrip, click the Design App button in the Apps tab.

App Testing Framework: Perform gestures on polar axes and UI


images
The App testing framework supports gestures on more UI components.

• Perform hover and press gestures in tests on polar axes.


• Perform press gestures in tests on UI images.

For example, perform interactive gestures on PolarAxes object pax and Image object im.
fig = uifigure;
pax = polaraxes(fig,'ThetaAxisUnits','radians');
im = uiimage(fig,'ImageSource','membrane.png','Position',[10 10 100 100]);
testCase = matlab.uitest.TestCase.forInteractiveUse;
testCase.hover(pax);
testCase.press(pax,[pi/2 0.5]);
testCase.press(im);

For more information, see the hover and press reference pages.

Functionality being removed or changed


GUIDE will be removed in a future release
Still runs

The GUIDE environment and the guide function will be removed in a future release.

After GUIDE is removed, existing GUIDE apps will continue to run in MATLAB but will not be editable
using the drag-and-drop environment in GUIDE. To continue editing an existing GUIDE app and help
maintain its compatibility with future MATLAB releases, use one of the suggested migration
strategies listed in the table.

App Development Migration Strategy How to Migrate


Frequent or ongoing Migrate your app to App Use the GUIDE to App Designer
development Designer Migration Tool for MATLAB on
mathworks.com
Minimal or occasional editing Export your app to a single Open the app in GUIDE and
MATLAB file to manage your select File > Export to
app layout and code using MATLAB-file
MATLAB functions

App Designer is the recommended app development environment in MATLAB. To create new apps,
use App Designer and the appdesigner function instead.

To learn more about migrating apps, see GUIDE Migration Strategies.

For more information about App Designer, go to Comparing GUIDE and App Designer on
mathworks.com.

9-38
App Building

javacomponent function and JavaFrame property will be removed in a future release


Warns

The javacomponent function and the JavaFrame figure property are undocumented and will be
removed in a future release. Update your code to use documented alternatives. For a list of
documented functionality that you can use instead, see Recommendations for Java and ActiveX Users
on mathworks.com.

actxcontrol, actxcontrollist, and actxcontrolselect functions will be removed in a future


release
Warns

The actxcontrol, actxcontrollist, and actxcontrolselect functions will be removed in a


future release. Update your code to use alternate functionality. For a list of functionality that you can
use instead, see Recommendations for Java and ActiveX Users on mathworks.com.

Support for running deployed web apps in Internet Explorer has been removed
Errors

Support for running deployed web apps in Internet Explorer® has been removed. Use the current
versions of Google Chrome (recommended), Safari, Firefox, or Microsoft Edge to run deployed web
apps instead.

For more information on supported web app browsers, see Supported Browsers and Platform
Incompatibilities (MATLAB Compiler).

Text alignment and font size have changed in table column and row headers
Behavior change

Starting in R2019b, table UI components created in App Designer or in figures created with the
uifigure function have a different visual appearance when they contain certain kinds of data.
Column and row headers of table UI components that contain numeric, logical, string, or cell array
data have these visual differences compared to previous releases:

• Smaller font size


• Column headers are left-aligned instead of center-aligned
• Row headers are center-aligned instead of left-aligned

For example, this code that creates a table UI component with mixed cell array data renders
differently in R2019b than it does in R2019a.

fig = uifigure;

d = {'Male',52,true;'Male',40,true;'Female',25,false};

uit = uitable(fig,'Data',d);
uit.ColumnName = {'Gender','Age','Authorized'};

9-39
R2019b

Starting in R2019a, the same visual differences apply to column and row headers in table UI
components that contain table array data. For example, this code that uses a table array to display
datetime values in a table UI component renders differently in R2019a than it does in R2018b.

fig = uifigure;

dates = datetime([2016,01,17; 2017,01,20],'Format','MM/dd/uuuu');


m = [10; 9];
tdata = table(dates,m,'VariableNames',{'Date','Measurement'});

uit = uitable(fig,'Data',tdata);
uit.RowName = 'numbered';

9-40
Performance

Performance

table Data Type Indexing: Improved performance when assigning


elements by subscripting into large table variables
table subscripted assignment into large table variables is significantly faster. Performance is now
essentially constant with the number of elements in each table variable.

• For example, when you use dot indexing to assign elements to a variable with 106 elements,
performance in R2019b is approximately 40x times faster, as shown below.

function timingTest()
t = table(zeros(1e6,1));
indices = randi(1e6,1,10000);

tic;
for i = indices
t.Var1(i) = rand;
end
toc
end

The approximate execution times are:

R2019a: 47.83 s

R2019b: 1.20 s
• Similarly, assignment using curly braces is faster. For example, when you assign into three table
variables with 106 elements, performance in R2019b is approximately 18x faster.

function timingTest()
t = table(zeros(1e6,1), ones(1e6,1), nan(1e6,1));
indices = randi(1e6,1,10000);

tic;
for i = indices
t{i,:} = rand;
end
toc
end

The approximate execution times are:

R2019a: 156.39 s

R2019b: 8.51 s

The code was timed on a Windows 10 system with a 3.6 GHz Intel Xeon W-2133 CPU by calling each
version of the timingTest function.

The larger the table variables are, the greater the performance improvement becomes. However, the
performance improvement occurs only when you make table subscripted assignments within a
function. There is no improvement when subscripting into tables at the command line, or within try-
catch blocks.

9-41
R2019b

datetime, duration, and calendarDuration Data Type Indexing:


Improved performance when assigning elements by subscripting into
large arrays
datetime, duration, and calendarDuration subscripted assignment into large arrays is
significantly faster. Performance is now essentially constant with the number of elements in an array.

• For example, when you assign into a datetime array with 106 elements, performance in R2019b
is approximately 106x times faster, as shown below.

function timingTest()
dt = datetime + hours(1:1e6);
indices = randi(1e6,1,10000);
rhs = NaT;

tic;
for i = indices
dt(i) = rhs;
end
toc
end

The approximate execution times are:

R2019a: 49.00 s

R2019b: 0.46 s
• Similarly, assignment into a duration array is faster. For example, when you assign into a
duration array with 106 elements, performance in R2019b is approximately 106x times faster.

function timingTest()
d = hours(1:1e6);
indices = randi(1e6,1,10000);

tic;
for i = indices
d(i) = NaN;
end
toc
end

The approximate execution times are:

R2019a: 48.66 s

R2019b: 0.46 s

The code was timed on a Windows 10 system with a 3.6 GHz Intel Xeon W-2133 CPU by calling each
version of the timingTest function.

The larger the arrays are, the greater the performance improvement becomes. However, the
performance improvement occurs only when you make subscripted assignments within a function.
There is no improvement when subscripting into datetime, duration, and calendarDuration
arrays at the command line, or within try-catch blocks.

9-42
Performance

datetime Data Type Indexing: Improved performance when referring


or assigning to date and time components of datetime arrays
Subscripted references and assignments to components of datetime arrays is significantly faster.

• For example, when you refer to a component of a datetime array with 104 elements, performance
in R2019b is approximately 25x times faster, as shown below.

function timingTest()
dt = datetime + hours(1:1e4);
indices = randi(1e4,1,10000);

tic;
for i = indices
x = dt.Hour(i);
end
toc
end

The approximate execution times are:

R2019a: 12.97 s

R2019b: 0.52 s
• Similarly, assignment into a component of a datetime array is faster. For example, when you
assign into a component of a datetime array with 104 elements, performance in R2019b is
approximately 32x times faster.

function timingTest()
dt = datetime + days(1:1e4);
indices = randi(1e4,1,10000);

tic;
for i = indices
dt.Hour(i) = 0;
end
toc
end

The approximate execution times are:

R2019a: 22.51 s

R2019b: 0.70 s

The code was timed on a Windows 10 system with a 3.6 GHz Intel Xeon W-2133 CPU by calling each
version of the timingTest function.

The larger the arrays are, the greater the performance improvement becomes. However, the
performance improvement occurs only when you make subscripted assignments within a function.
There is no improvement when subscripting into datetime arrays at the command line, or within try-
catch blocks.

9-43
R2019b

uitable Function: Faster performance when data type is numeric,


logical, or a cell array of character vectors
Tables created with the uitable function have better rendering performance, and higher frame
rates while scrolling when they contain certain kinds of data. The improvements occur when the
Data property contains numeric data, logical data, or a cell array of character vectors. The table
must be parented to a figure created with the uifigure function, or one of its child containers.

Tables containing these data types render up to 40% faster, and interaction performance (like
scrolling) is up to 75% faster. For example, on a test system, this code that uses numeric data renders
the table faster in R2019b than in previous releases.
rows = 10000;
columns = 25;
ndata = randi(30,[rows columns]);
fig = uifigure;
uit = uitable(fig,'Data',ndata);

unzip and gunzip Functions: Improved performance when extracting


contents of zip files and GNU zip files
Extracting the contents of zip files and GNU zip files using unzip and gunzip is significantly faster
when extracting files on network drives.

• For example, when you extract the contents of the example zip file myarchive.zip with a file
size of 53 MB on a network drive, performance in R2019b is approximately 1.5x faster, as shown
below.
function timingTest()
unzip myarchive.zip;
end

The approximate execution times are:

R2019a: 3.06 s

R2019b: 2.03 s
• Similarly, when you extract the contents of the example GNU zip file myotherarchive.gz with a
file size of 27 MB on a network drive, performance in R2019b is approximately 2x faster, as shown
below.
function timingTest()
gunzip myotherarchive.gz;
end

The approximate execution times are:

R2019a: 37.22 s

R2019b: 18.22 s

The code was timed on a Windows 10 test system with a 3.6 GHz Intel Xeon CPU E5-1650 CPU across
a Gigabit Ethernet connection using the timeit function:
timeit(@timingTest)

9-44
Performance

Results vary depending on several factors, including connection speed and whether the network files
are cached on the system.

9-45
R2019b

Software Development Tools

Unit Testing Framework: Run tests in parallel with your custom


plugins
You can now run unit tests in parallel when you extend the TestRunner instance with your custom
plugins. For more information, see Run Tests in Parallel with Custom Plugin.

Unit Testing Framework: Validate count in string constraints


The ContainsSubstring, IsSubstringOf, and Matches constraints can now count a string scalar
or character vector for a given number of times. To specify the number of occurrences, use the
'WithCount' parameter. For example:
import matlab.unittest.constraints.*
testCase = matlab.unittest.TestCase.forInteractiveUse;
testCase.verifyThat('This is long',ContainsSubstring('is','WithCount',2))

Verification passed.

testCase.verifyThat('Gain Main Rain',Matches('[GMR]ain','WithCount',2))

Verification failed.
---------------------
Framework Diagnostic:
---------------------
Matches failed.
--> Actual count does not match expected count.

Actual Count:
3
Expected Count:
2

Actual char:
Gain Main Rain
Regular Expression:
[GMR]ain

Performance Testing Framework: Visually compare two TimeResult


arrays
The matlab.perftest.TimeResult class has a new method comparisonPlot, which enables you
to visually compare the time measurement results of two equal-sized sets of performance tests.

App Testing Framework: Perform gestures on polar axes and images


The app testing framework supports gestures on more UI components.

• Perform hover and press gestures in tests on polar axes.


• Perform press gestures in tests on images.

9-46
Software Development Tools

Projects: Delete project definition files


You can now use matlab.project.deleteProject to easily stop managing your folder with a project and
delete all related project definition files without affecting the remaining files.

Compare Git Branches: Show differences and save copies


In a project under Git source control, you can now select any two revisions and examine file
differences. You can show differences between two development branches and save a copy of the
selected file on either branch. See Compare Branches.

Functionality being removed or changed


Character vectors are no longer equivalent to enumerations in qualifications
Behavior change

Starting in R2019b, actual and expected values in qualifications must have the same type when the
expected value is an enumeration of a handle class. For example, consider this enumeration class:
classdef MyClass < handle
enumeration
X
Y
end
end

The following test fails because 'X' does not represent the enumeration MyClass.X:
testCase = matlab.unittest.TestCase.forInteractiveUse;
testCase.verifySameHandle('X',MyClass.X)

Verification failed.
---------------------
Framework Diagnostic:
---------------------
verifySameHandle failed.
--> Values do not refer to the same handle.
--> Value must be a handle object. It is of class "char".
--> Classes do not match.
Actual Value class : [char]
Expected Handle Object class : [MyClass]

Actual char:
X
Expected Handle Object:
MyClass enumeration

In previous releases, the test passed because MATLAB treated 'X' as a representation of the
expected enumeration. This change of behavior affects tests using the IsSameHandleAs constraint
class or the following qualification methods: verifySameHandle, assumeSameHandle,
assertSameHandle, fatalAssertSameHandle, verifyNotSameHandle,
assumeNotSameHandle, assertNotSameHandle, and fatalAssertNotSameHandle.

9-47
R2019b

External Language Interfaces

C++ Interface: Options for publishing C++ interface library


MATLAB automatically renames classes, functions, enums, and member functions with C++ names
that are invalid in MATLAB using the matlab.lang.makeValidName function. For example,
MATLAB converts the class name _myclass in library mylib to x_myclass. As of R2019b, you can
modify x_myclass in the library definition file. For example, you can change the name to myclass.
When you use the class in MATLAB, type clib.mylib.myclass. Renaming C++ namespaces or the
MATLAB package is not supported.

To specify the shape for object pointer types as scalar for all functions in a library, use the name-value
pair argument 'TreatObjectPointerAsScalar' when building the library. To specify the shape
for const char * pointer types as scalar for all functions, use the
'TreatConstCharPointerAsCString' argument.

To provide a list of macro definitions, use the name-value pair argument DefinedMacros when
building the library. To provide a list of macro cancellations, use the UndefinedMacros argument.

For more information, see clibgen.generateLibraryDefinition and


clibgen.buildInterface.

C++ Interface: nullptr supported as output argument


As of R2019b, the “C++ interface returns type-specific empty values for nullptr” on page 9-50. To
test for fundamental nullptr types, call the isempty function. To test for nullptr objects, call the
clibIsNull function.

C++ Interface: Read-only (const) object support


As of R2019b, the “C++ interface treats read-only objects like C++” on page 9-50. To determine if a
C++ object is read-only, call the clibIsReadOnly function.

Java Interface: JRE version 1.8.0_202 support


The MATLAB interface to Java supports JRE version 1.8.0_202, providing improved security and
access to new Java features.

Out-of-Process Execution of C++ MEX Functions: Customize


environment variables
To customize the environment of a MEX host process that you use to execute a MEX function, call
mexhost with the "EnvironmentVariables" argument.

HTTP Web Services: Server authentication support for NTLM and


Kerberos protocols
The HTTP interface also supports these protocols for server authentication.

9-48
External Language Interfaces

• Windows — NTLM and Kerberos


• Linux and macOS — NTLM

For more information, see Server Authentication.

HTTP Web Services: Timeout options


MATLAB has new timeout options for transmitting messages using the HTTP interface.

• DataTimeout — timeout in seconds between packets on the network


• KeepAliveTimeout — how long the connection to the server stays open after an initial connect,
enabling multiple successive messages to be sent over the same connection
• ResponseTimeout — seconds to wait for the header of the response from the server after
sending the last packet of a request

For more information, see matlab.net.http.HTTPOptions.

Python Interface: Execute Python functions out of process


Run Python functions in processes that are separate from the MATLAB process. For more
information, see Out-of-Process Execution of Python Functionality. Use this mode to call functions in
third-party libraries that are not compatible with MATLAB.

Python Interface and Engine: Version 3.5 support discontinued


Support for Python version 3.5 is discontinued.

Compatibility Considerations
To ensure continued support for your applications, upgrade to a supported version of Python, version
3.6 or 3.7.

Perl 5.30.1: MATLAB support on Windows


As of R2019b Update 3, MATLAB on Windows ships with Perl version 5.30.1.

• See www.perl.org for a standard distribution of perl, perl source, and information about using
perl.
• See https://metacpan.org/pod/HTML::Parser for a standard distribution of HTML::Parser, source
code, and information about using HTML::Parser.
• See https://metacpan.org/pod/HTML::Tagset for a standard distribution of HTML:Tagset, source
code, and information about using HTML:Tagset.

Compatibility Considerations
If you use the perl command on Windows platforms, see www.perl.org for information about using
this version of the Perl programming language.

9-49
R2019b

Compiler support changed for building MEX files and standalone


MATLAB engine and MAT-file applications
Support Compiler Platform
Added Microsoft Visual Studio 2019 for C and C++ Windows
Discontinued Intel Parallel Studio XE 2015 and XE 2016 for Fortran Windows

macOS

To ensure continued support for building your MEX files, consider upgrading to another supported
compiler. For an up-to-date list of supported compilers, see Supported and Compatible Compilers.

Functionality being removed or changed


C++ interface treats read-only objects like C++
Behavior change

A C++ read-only object is an object declared with the C++ const attribute. You might get such an
object as the output of a function or as a data member of a class. Starting in R2019b, the C++
interface for MATLAB honors the const type qualifier ensuring that the MATLAB behavior matches
the C++ behavior of const-qualified types. MATLAB throws an error if you use a read-only object as
follows:

• Passing the object to functions with non-const inputs


• Calling a non-const method on the object
• Modifying object properties

To test if an object is read-only, call the clibIsReadOnly function.

In R2019a, the interface ignores the const type qualifier, allowing the MATLAB user to utilize const
objects incorrectly.

C++ interface returns type-specific empty values for nullptr


Behavior change

Starting in R2019b, the C++ interface returns type-specific empty values for functions that return
nullptr. For more information about nullptr return types. see MATLAB to C++ Data Type
Mapping.

• For type double, MATLAB continues to return [] for the value double.empty.
• For all other fundamental types, MATLAB returns an MLTYPE.empty value. To test for nullptr
types, call the isempty function.
• For nonfundamental types, MATLAB returns a nullptr object. To test for nullptr objects, call
the clibIsNull function.

In R2019a, for fundamental and nonfundamental types, the interface returns a double.empty ([])
value.

For example, suppose that these C++ functions return nullptr:


class A {
public:

9-50
External Language Interfaces

double val;
};

// Function returning nullptr object


A* returnNullptrObject() {
return nullptr;
}

// Functions returning nullptr primitive type ptr


double* returnDoubleNullptr () {
return nullptr;
}

const char* returnStringNullptr () {


return nullptr;
}

R2019a R2019b
For objects, MATLAB returns [] MATLAB returns nullPtr for an object of class A.
(double.empty).
nullReturn = clib.nullptr.returnNullptrObject
nullReturn = clib.nullptr.returnNullptrObject
nullReturn =
nullReturn = null A
[]
For fundamental types, MATLAB returns []. MATLAB returns empty string array for type
const char*.
nullReturn = clib.nullptr.returnStringNullptr
nullReturn = clib.nullptr.returnStringNullptr
nullReturn =
[] nullReturn =
0×0 empty string array
For type double, MATLAB returns []. No change. MATLAB returns [].

nullReturn = clib.nullptr.returnDoubleNullptr
nullReturn = clib.nullptr.returnDoubleNullptr

nullReturn = nullReturn =
[] []

pyversion is not recommended


Still runs

pyversion is not recommended. Use pyenv instead. There are no plans to remove pyversion at
this time.

To execute Python functions out of process, MATLAB provides a new function, pyenv. This function
configures Python environment settings, including the version. Even if you do not use the out-of-
process feature, MathWorks recommends using pyenv for managing Python settings. For more
information, see Out-of-Process Execution of Python Functionality.

C MEX and engine applications: true, false, and bool defined by <stdbool.h>
Behavior change

9-51
R2019b

The definition for true, false, and bool has changed for building MEX files and standalone
MATLAB engine and MAT-file applications with C99 compatible compilers on Windows and Linux
platforms. MATLAB defines these values using <stdbool.h> as defined by IEEE Std 1003.1:

The <stdbool.h> header shall define the following macros:


bool
Expands to _Bool.
true
Expands to the integer constant 1.
false
Expands to the integer constant 0.
_bool_true_false_are_defined
Expands to the integer constant 1.

In R2019a and earlier, MATLAB defined these values on Windows and Linux platforms as:

• true — #defined as 1
• false — #defined as 0
• bool — typedef as unsigned char

For Apple macOS platforms, there is no change.

actxcontrol, actxcontrollist, and actxcontrolselect functions will be removed in a future


release
Warns

The actxcontrol, actxcontrollist, and actxcontrolselect functions will be removed in a


future release. MATLAB will support COM server objects only.

9-52
10

R2019a

Version: 9.6

New Features

Bug Fixes

Compatibility Considerations
R2019a

Environment

Live Editor Controls: Add check boxes, edit fields, and buttons to set
variable values and run the live script
You can add check boxes and edit fields to your live scripts to interactively set variable values. You
also can add a button to run the live script when clicked.

To add a check box, edit field, or button, go to the Live Editor tab, click Control , and select
from the available controls. For more information, see Add Interactive Controls to a Live Script.

Live Editor Controls: Specify what code to run when a control value
changes
By default, when you change the value of an interactive control, the Live Editor runs the section that
contains the control. You can now configure an interactive control to run all sections, run the current
section and all remaining sections, or to do nothing.

To configure the control, right-click the control and select Configure Control. Then, in the
Execution section, select from the available options.

Configuring an interactive control to do nothing when changed is useful when your live script
contains multiple interactive controls and you only want to run the code after changing all of their
values. Add a button to the live script to run the code when clicked.

Live Editor Controls: Hide code when sharing and exporting live
scripts with interactive controls
You can hide the code in a live script, showing only the interactive controls, output, and formatted
text. Hiding the code is useful when sharing and exporting live scripts.

To hide the code in a live script, click the hide code button to the right of the live script. To show
the code again, click the output inline button or the output on right button.

If you export the live script to PDF, HTML, LaTeX, or Microsoft Word, the code remains hidden.

Live Editor Export: Save live scripts and functions as Microsoft Word
documents
To create editable, static documents capable of being viewed outside of MATLAB, save live scripts
and functions as Microsoft Word documents. To save a live script or function as a Microsoft Word
document, on the Live Editor tab, select Save > Export to Word. This format is only available on
Windows platforms.

For more information about sharing live scripts and functions, see Share Live Scripts and Functions.

10-2
Environment

Live Editor Output: Enable animations in plots to show changes in


data over time
You can enable for-loop animations in the Live Editor to show changes in plotted data over time.

To enable animations in the Live Editor, set the matlab.editor.AllowFigureAnimations setting


to true:

s = settings;
s.matlab.editor.AllowFigureAnimation.PersonalValue = true;

Note Enabling animations disables support for uicontrols in the Live Editor.

For example, this code turns on animations in the Live Editor, and then animates a line growing as it
accumulates 2,000 data points. The drawnow function displays the changes after each iteration
through the loop.

s = settings;
s.matlab.editor.AllowFigureAnimation.PersonalValue = true;

h = animatedline;
axis([0 4*pi -1 1])
x = linspace(0,4*pi,2000);

for k = 1:length(x)
y = sin(x(k));
addpoints(h,x(k),y);
drawnow
end

10-3
R2019a

Live Editor Output: Interactively clean categorical data and filter


datetime and duration variables in table output
In the Live Editor, you can interactively clean categorical data and filter datetime and duration
variables in table output.

To clean a categorical variable in a table, click the down arrow to the right of the variable name
and select Edit Categories. Use the available options to create, remove, and merge categories.

To filter a datetime or duration variable in a table, click the down arrow to the right of the
variable name and select from the available filtering options.

To add the generated code to your live script, click the Update Code button below the table. Adding
the generated code to your live script ensures that the cleaning and filtering is reproduced the next
time you run the live script.

Live Editor Output: Interactively change the data type of variables in


table output
In the Live Editor, you can interactively change the data type of a variable in table output. Right-click
the variable column in the table, select Convert from datatype to, and select from the available
options.

10-4
Environment

Live Editor Functions: Automatically convert selected code to a


function
Break large scripts or functions into smaller pieces by converting selected code into functions in files
or local functions. With one or more lines of code selected, on the Live Editor tab, in the Code
section, click Refactor, and then select from the available options. MATLAB creates a function
with the selected code and replaces the original code with a call to the newly created function.

MATLAB Online: Share folders and collaborate with others


Share your folders with a view-only link, or invite individual collaborators and set their editing
permissions. Invitations can be accepted or declined.

After a folder is shared, you can manage the permissions of invited members, rescind invitations, or
send additional invitations at any time.

Projects: Organize, manage, and share your work using projects


Create projects in MATLAB to organize and share your work with others. Use projects to find files
required to run your code, manage and share files and settings, and interact with source control.

To create a project from an existing folder of files, in the desired folder, go to the Home tab, and
select New > Project > From Folder. MATLAB creates the project and adds your existing files to
the project.

MATLAB Startup: Execute MATLAB script or function non-interactively


To call a MATLAB script or function non-interactively, start MATLAB with the -batch option. The
option is for non-interactive use in both scripting and command-line workflows. MathWorks
recommends that you use the -batch option instead of the -r statement option for these cases.

For example, to run unit tests you created for your programs, from the operating system command
prompt, type:

matlab -batch runtests

10-5
R2019a

MATLAB:

• Starts without the desktop


• Does not display the splash screen
• Executes the runtests function
• Logs text to stdout and stderr
• Exits automatically with status

To test if a session of MATLAB is running in batch mode, call the batchStartupOptionUsed


function.

For more information, see matlab (Windows), matlab (macOS), or matlab (Linux).

Toolbox Packaging: Install required add-ons with custom toolboxes


When creating a custom toolbox, MATLAB detects the add-ons required by the toolbox. When
someone installs your toolbox, the toolbox also downloads and installs the required add-ons.

MATLAB Drive: View MATLAB files in MATLAB Drive Online (April 2019)
When using your MATLAB Drive online, double-click any MATLAB file or live script to preview its
contents. When previewing these files, you also have the option to open them in MATLAB Online.

For more information, see “Access Files in Your MATLAB Drive”.

MATLAB Drive: Improvements to MathWorks account sign on (May


2019)
Signing in to your MathWorks account from MATLAB Drive online has improved.

10-6
Language and Programming

Language and Programming

append Function: Combine strings


Combine text in string arrays, character vectors, and cell arrays of character vectors using the
append function.

Unlike the strcat function, append treats all input data types the same. For example, if an input
argument has trailing whitespace characters, then append always keeps them, even when the
argument is a character vector.

MException class: Provide a suggested fix for an uncaught exception


Provide a suggested fix, using the Correction class, for an exception when it is thrown and not
caught. Use the addCorrection method to add the correction to an MException object.

Functionality being removed or changed


Folders named resources are not allowed on the MATLAB path
Warns

Starting in R2019a, the resources folder is a reserved folder, and folders with the name resources
are not allowed on the MATLAB path. In previous releases, these folders were allowed on the
MATLAB path.

If a folder named resources is specified when calling the addpath, userpath, or pathdef
functions, MATLAB returns a warning and the folder is not added to the path. If you have a folder
named resources, MATLAB is unable to run any of the contents of that folder, even if the
resources folder is the current folder.

Rename all folders on the path named resources, and move any files you want to run in MATLAB
out of folders named resources.

Cell array expansion is consistent with general array expansion


Behavior change

Starting in R2019a, the dimensions of an expanded cell array are consistent whether you use curly
braces or parentheses for indices. Previously, the output dimensions were different when you did not
specify indices for all dimensions. Indexing with curly braces now matches the previous behavior for
indexing with parentheses, which is consistent with general array expansion.

For more information, see the Compatibility Considerations section of cell.

Structure array expansion is consistent with general array expansion


Behavior change

Starting in R2019a, the dimensions of an expanded structure array are consistent whether you assign
a value to a single field using dot notation or assign an entire structure to the array. Previously, the
output dimensions were different when you did not specify indices for all dimensions. Assigning to a
field using dot notation now matches the previous behavior of assigning a structure, which is
consistent with general array expansion.

10-7
R2019a

For more information, see the Compatibility Considerations section of struct.

Class properties using size validation no longer unconditionally reshape empty arrays
Behavior change

In previous releases, if a class defined a property using a size validation that contained unrestricted
dimensions (indicated by a colon, such as (:,:)), then assigning an empty array of any size to the
property resulted in an empty array of size (0,0). For example, given this class definition:
classdef MyClass
properties
Prop1(:,:)
Prop2
end
end

Assigning an empty array of any dimension to Prop1 always resulted in an empty array of dimensions
(0,0).
obj = MyClass;
obj.Prop1 = double.empty(0,5);
size(obj.Prop1)

ans =

0 0

Assigning an empty array to Prop2 produces the correct result because size validation with
unrestricted dimensions is not used in the class.
obj = MyClass;
obj.Prop2 = double.empty(0,5);
size(obj.Prop2)

ans =

0 5

Starting in R2019a, using unrestricted size validation for properties does not cause the size of empty
arrays assigned to the properties to be reshaped to (0,0). In R2019a, the same class definition
produces these results for assignment to Prop1.
obj = MyClass;
obj.Prop1 = double.empty(0,5);
size(obj.Prop1)

ans =

0 5

Defining classes and packages using schema.m will not be supported in a future release
Still runs

Support for classes and packages defined using schema.m files will be removed in a future release.
Replace existing schema-based classes with classes defined using the classdef keyword.

First argument to ismethod must be an object


Behavior change in future release

10-8
Language and Programming

The ismethod function is documented to look for a method of the object that is specified as the first
input. However, the ismethod function treats string and char inputs as a class name and looks for
the specified method in that class. Therefore, you cannot use ismethod to find a method of an input
object that is a string or char array. In future releases, ismethod will return true only if the
second input is the name of a method of the first input object. ismethod will not treat the first input
as a class name.

For code that uses ismethod with a class name specified as a string scalar or character vector, you
can substitute this expression as an alternative that will work in current and future versions.

any(strcmp('methodName', methods('ClassName')))

Program files larger than 128 MB or with high complexity will not be supported
Behavior change in future release

In a future release, running or opening program files larger than approximately 128MB will not be
supported. For files that contain only code (for example, .m and .p files), this limit will affect the file
size. For files that store more than just code (for example, .mlx files), it will affect the size of the
code. Running statements larger than 128MB, either directly in the Command Window or using the
eval function, also will not be supported. In addition, code with high levels of complexity, such as a
large number of deeply nested if statements, will not be supported. Currently, these files and code
are supported but can cause errors or unpredictable behavior.

Code that is too large or complex will not run or open in MATLAB, and MATLAB will display an error.

Large program file or statement sizes often occur when using large portions of code (for example,
over 500 lines) to define variables with constant values. To decrease the size of these files, consider
defining the variables and saving them in a data file (for example, a MAT-file or .csv file). Then you
can load the variables instead of executing code to generate them. This not only decreases the file
size of your program, but can also increase performance.

10-9
R2019a

Data Analysis
xcorr and xcov Functions: Compute cross-correlation and cross-
covariance in core MATLAB
You can now compute the cross-correlation and cross-covariance of data using MATLAB. Previously,
xcorr and xcov were only available in the Signal Processing Toolbox.

detrend Function: Remove piecewise polynomial trends, set continuity


requirements, and specify sample points
The detrend function now offers additional functionality.

• In addition to the constant and linear methods for removing piecewise trends, you can specify
higher degree polynomials. For example, detrend(A,3) removes a cubic trend from the data in
A.
• When supplying break points, you can use the 'Continuous' parameter to specify whether the
fitted trend must be continuous.
• The 'SamplePoints' parameter allows you to define the sample points associated with the input
data.

groupcounts Function: Count the number of group elements for


arrays, tables, and timetables
To count the number of elements in a group, use the groupcounts function.

grouptransform Function: Transform array data by group


In addition to tables and timetables, you can now transform data in an array by group using the
grouptransform function.

filloutliers, isoutlier, and rmoutliers Functions: Detect outliers using


percentiles
The filloutliers, isoutlier, and rmoutliers functions now offer Winsorization for detecting
outliers using the 'percentiles' option.

fillmissing and filloutliers Functions: Fill missing and outlier data


using modified Akima interpolation
You can now fill missing and outlier data with modified Akima interpolation using the 'makima'
option in the fillmissing and filloutliers functions.

fillmissing Function: Specify missing value locations


To specify the locations of missing data when using the fillmissing function, use the
'MissingLocations' parameter.

10-10
Data Analysis

min and max Functions: Return index information when operating on


more than one dimension and specify linear indices
When simultaneously operating on more than one dimension with the min and max functions, you can
now return index information corresponding to the minimum and maximum values.

You can also return the linear indices corresponding to the minimum and maximum values of the
input array using the 'linear' option.

tall Arrays: Write custom sliding-window algorithms to operate on tall


arrays
The functions matlab.tall.movingWindow and matlab.tall.blockMovingWindow enable you
to write custom algorithms for sliding-window functions to operate on tall arrays.

tall Arrays: Operate on tall arrays with more functions, including


groupcounts, intersect, and svd
The functions listed in this table now support tall arrays as inputs. For a complete list of supported
functions, type methods tall. For more information on usage and limitations, see the Extended
Capabilities section at the bottom of each reference page.

addvars movevars
cospi normalize
groupcounts removevars
grouptransform sinpi
inner2outer splitvars
intersect svd
mergevars union

In addition, some functions have removed limitations with tall arrays.

Functions Added Support


stack The two-output syntax [S,iu] = stack(___)
now supports tall arrays. The second output
returns indices that describe the mapping of rows
in the stacking operation.

Previously, multiple outputs were not supported


for tall arrays.
groupsummary Grouped calculations on tall matrices and arrays
are now supported.

Previously, the first input was required to be a tall


table or tall timetable.

10-11
R2019a

Functionality Being Removed or Changed


Default random number generator change for tallrng
Behavior change

Starting in R2019a, the default random number generator for tallrng is threefry. This generator
offers performance enhancements for parallel calculations over the old default. In releases up to
R2018b, the default random number generator for tallrng was combRecursive.

With a different default generator, MATLAB will generate different sequences of random numbers by
default in the context of tall arrays. However, the statistics of these calculations will remain
unaffected. Therefore, you should update any code that relies on the specific random numbers being
generated. However, most calculations on the random numbers should be unaffected.

To set the generator to the settings used by default in R2018b and earlier releases, use the command:

tallrng(0,'combRecursive')

10-12
Data Import and Export

Data Import and Export

readmatrix, readvars, and readcell Functions: Read tabular data as a


matrix, variables, or a cell array
Read column-oriented data from text or spreadsheet files into a matrix, variables, or a cell array.

• readmatrix — Read homogeneous column-oriented data into a matrix.


• readvars — Read column-oriented data into variables. Each variable corresponds to a column of
data in the file.
• readcell — Read heterogeneous data into a cell array.

writematrix and writecell functions: Write tabular data from a matrix


or cell array to a text or spreadsheet file
Write data from a matrix or a cell array to a text or spreadsheet file.

• writematrix — Write a homogeneous array to a file.


• writecell — Write a cell array to a file.

readtimetable and writetimetable Functions: Read and write


timetables
Read and write timetables in MATLAB.

• Use the readtimetable function to read timetables from text or spreadsheet files.
• Use the writetimetable function to write timetables to text or spreadsheet files.

detectImportOptions Function: Improve detection of import options


for text and spreadsheet files
Improve the detection of import options for text and spreadsheet files by passing additional
information to the detectImportOptions function using these name-value pairs.

• 'ThousandsSeparator' — Character separating thousands groups (numeric variables only)


• 'DecimalSeparator' — Character separating integer part from fractional part (numeric
variables only)
• 'TrimNonNumeric' — Remove non-numeric characters from numeric variables (numeric
variables only)
• 'ConsecutiveDelimitersRule' — Procedure to handle consecutive delimiters (text files only)
• 'LeadingDelimitersRule' — Procedure to handle leading delimiters (text files only)
• 'TreatAsMissing' — Text to interpret as missing data (text files only)
• 'ReadRowNames' — Read first column as row names
• 'ReadVariableNames' — Read first row as variable names

For more information, see the setvaropts and detectImportOptions reference pages.

10-13
R2019a

parquetread, parquetwrite, and parquetinfo Functions: Read, write,


and get information from Parquet files
Import and export column-oriented data from Parquet files in MATLAB. Parquet is a columnar storage
format that supports efficient compression and encoding schemes. To work with the Parquet file
format, use these functions.

• parquetread — Read columnar data from a Parquet file.


• parquetwrite — Write columnar data to a Parquet file.
• parquetinfo — Get information about a Parquet file.

For more information on the Parquet file format, see https://parquet.apache.org/.

write Function: Write tall arrays to Parquet files


The write function now supports writing tall arrays to Parquet files. To write a tall array, set the
FileType parameter to 'parquet', for example:

write('C:\myData',tX,'FileType','parquet')

Import Tool: Generate improved code when importing from text files
Import Tool now functions consistently across different platforms and generates code that is easy to
read for importing text files. For more information, see Import Text File Data Using Import Tool.

thingSpeakRead and thingSpeakWrite Functions: Read or write data


to the ThingSpeak IoT platform
Access IoT data in ThingSpeak™ channels:

• Use thingSpeakRead to read data from ThingSpeak channels.


• Use thingSpeakWrite to write data to ThingSpeak channels.

For more information on the ThingSpeak platform, see https://thingspeak.com/.

writetable and imwrite Functions: Write to web-based storage


services like Amazon Web Services and Azure Blob Storage
Write tabular data and image files to remote locations using the writetable and imwrite
functions. When writing data to remote locations, you must specify the full path using a uniform
resource locator (URL). For example, write a csv file and a jpg file to Amazon S3 Cloud:

writetable(T,'s3://bucketname/path_to_file/my_text_file.csv');
imwrite(I,'s3://bucketname/path_to_file/my_image.jpg');

For more information on setting up MATLAB to access your online storage service, see Work with
Remote Data.

10-14
Data Import and Export

ParquetDatastore Object: Create a datastore for a collection of


Parquet files
Read a collection of Parquet files into MATLAB workspace using parquetDatastore.

For more information on the Parquet file format, see https://parquet.apache.org/.

ImageDatastore Object: Create a subset of an existing datastore


Create a subset of an image datastore using the subset method.

DsFileSet Object: Create a subset of a file collection


You can create a subset of a DsFileSet object by using the subset method. The DsFileSet object
helps you manage the iterative processing of large collections of files.

FileDatastore Object: Read large files by importing the file in smaller


portions
Read and process large files in smaller portions. For example, you can create a datastore that reads
one array at a time from a large MAT-file that does not fit in the available memory. To set up your
datastore to perform partial reads, use these name-value pairs: 'ReadMode', 'PreviewFcn', and
'BlockSize'.

For more information, see fileDatastore.

Datastores: Combine and transform datastores


Perform combine and transform operations on existing datastores.

• combine — Combine two or more datastores and return a new datastore representing the
underlying datastores.
• transform — Transform an input datastore by using a specified transformation function and
return the transformed datastore.

Custom Datastore: Read Hadoop based data from files, databases,


and other non-file-based locations
Author a custom datastore to access data stored in files or non-file-based data sources such as a
databases using matlab.io.datastore.HadoopLocationBased mixin. Use this extension to
specify the location of your data in Hadoop®. A custom datastore with the HadoopLocationBased
mixin makes computations more efficient by leveraging the location of the data. With your custom
datastore you can perform big data analysis by using tall arrays and mapreduce.

For more information on the custom datastore framework, see Develop Custom Datastore.

VideoReader function: Generate C and C++ code


The VideoReader function supports C and C++ code generation using MATLAB Coder™.

10-15
R2019a

ind2rgb function: Generate C and C++ code


The ind2rgb function supports C and C++ code generation using MATLAB Coder.

Scientific File Format Libraries: NetCDF Library upgraded to version


4.6.1
The NetCDF library is upgraded to version 4.6.1.

web function: Open external sites in system browser instead of


MATLAB browser
You can change the default behavior of the web function to open external sites in your system
browser instead of the MATLAB browser. Using the system browser is recommended when opening
external sites. To change the default behavior, go to the Home tab, and in the Environment section,
click Preferences. Select MATLAB > Web, and in the System Web browser section, select Use
system web browser when opening links to external sites (recommended).

Functionality being removed or changed


NumberOfChannels property of the audioplayer and audiorecorder Objects is not
recommended
Still runs

The NumberOfChannels property of the audioplayer and audiorecorder objects is not


recommended. Use the name NumChannels instead. To update your code, change instances of
NumberofChannels to NumChannels. The values of the properties are the same. There are no plans
to remove the NumberOfChannels property at this time.

web Function
Behavior change in future release

In future releases, the web function will open external sites using your system browser by default.
Currently, the web function opens external sites using the MATLAB browser. Using the system
browser is recommended when opening external sites.

To change the default browser, go to the Home tab, and in the Environment section, click
Preferences. Select MATLAB > Web and in the System Web browser section, select Use system
web browser when opening links to external sites (recommended).

hdftool is not recommended


Still runs

In a future release, hdftool will be removed. To import HDF4 or HDF-EOS files, use the hdfread
function instead.

csvread and csvwrite functions are not recommended


Still runs

csvread and csvwrite are not recommended. Use readmatrix and writematrix instead. There
are no plans to remove csvread and csvwrite.

10-16
Data Import and Export

This table shows typical usages of csvread and csvwrite and how to update your code to use
readmatrix and writematrix instead.

Not Recommended Recommended


M = csvread(filename) M = readmatrix(filename)
csvwrite('mydata.txt',M) writematrix(M,'mydata.txt')

For more information, see readmatrix and writematrix.

dlmread and dlmwrite functions are not recommended


Still runs

dlmread and dlmwrite are not recommended. Use readmatrix and writematrix instead. There
are no plans to remove dlmread and dlmwrite.

This table shows typical usages of dlmread and dlmwrite and how to update your code to use
readmatrix and writematrix instead.

Not Recommended Recommended


M = dlmread(filename) M = readmatrix(filename)
dlmwrite('mydata.txt',M) writematrix(M,'mydata.txt')

For more information, see readmatrix and writematrix.

xlsread and xlswrite functions are not recommended


Still runs

xlsread and xlswrite are not recommended. Instead of xlsread and xlswrite:

• Use readtable and writetable for reading and writing mixed numeric and text data.
• Use readmatrix and writematrix for reading and writing homogeneous text or numeric data.
• Use readcell and writecell for reading and writing mixed numeric and text data.

There are no plans to remove xlsread and xlswrite.

This table shows typical usages of xlsread and xlswrite and how to update your code to use the
recommended read and write functions.

Not Recommended Recommended


Read spreadsheet data as a matrix using Read spreadsheet data as a table:
xlsread:
T = readtable(filename)
M = xlsread(filename)
However, to continue reading your data as a matrix,
use:

M = readmatrix(filename)

10-17
R2019a

Not Recommended Recommended


Read spreadsheet data as a cell array using Import spreadsheet data as a table:
xlsread:
T = readtable(filename)
[~,~,C] = xlsread(filename)
However, to continue importing your data as a cell
arrary, use:

C = readcell(filename)
Read a specific sheet and range as a matrix Read a specific sheet and range as a table:
using xlsread:
T = readtable(filename,'Sheet',sheet,'Range',range)
M = xlsread(filename,sheet,range)
However, to continue reading your data as a matrix,
use:

M = readmatrix(filename,'Sheet',sheet,'Range',range)
Read a specific sheet and range as a cell array Read a specific sheet and range as a table:
using xlsread:
T = readtable(filename,'Sheet',sheet,'Range',range)
[~,~,C] = xlsread(filename,sheet,range)
However, to continue reading your data as a cell
array:

C = readcell(filename,'Sheet',sheet,'Range',range)
Write tabular data to spreadsheets using To write tabular data to spreadsheets, use one of
xlswrite: these options instead.

xlswrite(filename,M) Write a table:

writetable(T,filename)

Write a matrix:

writematrix(M,filename)

Write a cell array:

writecell(C,filename)

For more information, see readmatrix, writematrix, readcell, writecell, readtable, and
writetable.

HadoopFileBased is not recommended


Still runs

HadoopFileBased is not recommended. Use HadoopLocationBased instead. There are no plans to


remove HadoopFileBased.

Starting in R2019a, use the HadoopLocationBased mixin to add Hadoop support to your custom
datastore. The HadoopLocationBased mixin provides support for non-file-based data where as
HadoopFileBased supports file-based data only.

For more information on the custom datastore framework, see Develop Custom Datastore.

10-18
Mathematics

Mathematics

Solve assignment problem with matchpairs and equilibrate


New functions enable you to solve the assignment problem in a variety of contexts.

• matchpairs — Create a linear mapping between the rows and columns of a cost matrix. This
assigns rows to columns in such a way that the global cost is minimized.
• equilibrate — Permute and rescale a matrix A such that the new matrix B = R*P*A*C has only
1s and -1s on its diagonal, and all off-diagonal entries are not greater than 1 in magnitude. When
computing a preconditioner to iteratively solve a linear system, use equilibration to improve the
condition of a matrix and allow for improved preconditioners.

graph and digraph Objects: Construct graphs with categorical nodes


The graph, digraph, and addedge functions now support categorical node names as inputs. This
enables you to use data that is imported as categorical to create a graph, without the need for
data type manipulation.

10-19
R2019a

Graphics
parallelplot Function: Visualize tabular or matrix data with multiple
columns by using a parallel coordinates plot
To create a parallel coordinates plot, use the parallelplot function. Rows of the input data
correspond to lines in the plot, and columns of the input data correspond to coordinates in the plot.
To group the lines in the plot, you can use either the 'GroupVariable' name-value pair argument
with tabular data or the 'GroupData' name-value pair argument with matrix data.

Data Tips: Pin and customize data tips in charts


The data tips that appear as you hover over a chart become persistent (pinned) when you click them.
Clicking a second time unpins the data tip.

For some types of charts, you can customize the contents of the data tips. For example, you can edit
the data tip labels, change the displayed values, or change the font size. Also, you can add or delete
rows from the data tips. Charts that support these customizations include Scatter, Stair, Stem,
Line, and Surface objects with a DataTipTemplate property.

• To edit the labels interactively, double-click a label, type the text you want, and then click outside
the data tip. To make other customizations interactively, right-click the data tip and select Edit
Properties.... Use the fields in the Property Inspector that opens to make any changes.
• To customize the data tip programmatically, use the DataTipTemplate property of the chart
object. For example, this code plots sample patient data from a table as a scatter chart. Then it
changes the font size and labels of the data tips. For more information, see DataTipTemplate.
tbl = readtable('patients.xls');
s = scatter(tbl.Weight,tbl.Height);
s.DataTipTemplate.FontSize = 12;
s.DataTipTemplate.DataTipRows(1).Label = 'Weight';
s.DataTipTemplate.DataTipRows(2).Label = 'Height';

You can add a new row to the data tip using the dataTipTextRow function. For example, add a
third row that shows the patient name from the table.

s.DataTipTemplate.DataTipRows(3) = dataTipTextRow('Name',tbl.LastName);

Axes Interactions: Customize chart interactions such as dragging to


pan or scrolling to zoom
Create a customized set of chart interactions by setting the Interactions property of the axes.
These interactions are built into the axes and are available without having to select any buttons in the
axes toolbar. Some types of interactions are enabled by default, depending on the content of the axes.

For more information, see Control Chart Interactivity.

10-20
Graphics

Ruler Panning: Pan an axis to change its limits without having to use
the pan tool
Drag an axis to change the limits along a dimension of a plot. This functionality is available for most
Cartesian plots, even when the pan tool in the axes toolbar is disabled.

Property Inspector: Navigate and control visibility of graphics objects


interactively
You can use the object browser that appears at the top of the Property Inspector to navigate and
control the visibility of graphics objects. When you select an object using the object browser, the
object appears selected in the figure and the properties appear in the inspector.

The object browser has a collapsed view and an expanded view.

• The collapsed view (default view) shows the currently selected object and its direct hierarchy.
Click one of the object names to see its properties in the Property Inspector.

• The expanded view shows the graphics object hierarchy of the figure. Right-click an object name
to show, hide, or delete the graphics object. Select multiple objects using Ctrl+click.

Geographic Plots: Geographic rulers, scale bar, CurrentPoint, and


ginput
Plots on geographic axes include customizable rulers and a scale bar.

10-21
R2019a

Use the geotickformat function to customize rulers.

GeographicAxes support the CurrentPoint property. Use this property to get the current
coordinates of the mouse pointer on a geographic axes.

Graphics Export: Export axes with tighter cropping using the axes
toolbar
Click or tap the export button in the axes toolbar to save the axes as an image or PDF file. The saved
content is tightly cropped around the axes with minimal white space.

Chart Resizing: Resize charts with improved layouts


The layout is improved when you resize a chart that can be a child of a figure (such as a heatmap).
This automatic resizing behavior adjusts the font sizes and spacing between elements in the chart to
provide the best possible presentation for the new size.

Changing the FontSize property of a chart disables the automatic resizing of the fonts.

10-22
Graphics

Colors Values: Specify colors using hexadecimal color codes


Specify hexadecimal color codes when setting the color of graphics objects. For example,
set(gca,'XColor','#FF8800') sets the x-axis color to orange. Use either the six-digit or three-
digit form to specify a color. The characters are not case-sensitive. Thus, '#FF8800', '#ff8800',
'#F80', and '#f80' are equivalent.

Categorical Values: Specify categorical arrays for functions and


objects that use lists of text
Many functions and object properties that use lists of text items now accept categorical arrays in
addition to cell arrays and string arrays. When you specify a categorical array, MATLAB uses the
values in the array, not the categories. Thus you might need to write additional code to extract the
values you want to use. For example, this code finds the unique entries of the cities categorical
array before setting the x-axis tick labels.
bar([10 20 30])
cities = categorical({'Boston','Boston','Berlin','Paris','Berlin'});
xticklabels(unique(cities))

See the documentation for a specific function or object to determine whether it accepts categorical
values.

rendererinfo Function: Get renderer information for any axes


Use the rendererinfo function to get information about the graphics renderer used for any axes or
chart that can be a child of a figure.

Compatibility Considerations
Use the rendererinfo function instead of the opengl function to get information about the
graphics renderer.

Functionality being removed or changed


Using the opengl function to get information about the graphics renderer is not
recommended
Still runs

Using the opengl function to get information about the graphics renderer is not recommended.
Specifically, these syntaxes are not recommended:

• opengl info
• d = opengl('data')

There are no plans to remove support for these syntaxes at this time. Instead of calling opengl to get
the renderer information, call the rendererinfo function instead:
info = rendererinfo(ax)

Specify ax as any type of axes or a chart that can be a child of a figure (such as a heatmap). The
output is a structure containing most of the same information as the opengl function provides.

10-23
R2019a

Fields in opengl Structure Corresponding Fields in rendererinfo


Structure
d.Version info.Version
d.Vendor info.Vendor
d.Renderer info.RendererDevice
d.RendererDriverVersion info.Details.RendererDriverVersion
d.RendererDriverReleaseDate info.Details.RendererDriverReleaseDate
d.MaxTextureSize info.Details.MaxTextureSize
d.Visual No longer needed
d.Software This information is stored in
info.GraphicsRenderer, but to get the
equivalent logical value, use
strcmp(info.GraphicsRenderer,'OpenGL
Software')
d.HardwareSupportLevel info.Details.HardwareSupportLevel
d.SupportsGraphicsSmoothing info.Details.SupportsGraphicsSmoothing
d.SupportsDepthPeelTransparency info.Details.SupportsDepthPeelTranspar
ency
d.SupportsAlignVertexCenters info.Details.SupportsAlignVertexCenter
s
d.Extensions No longer needed
d.MaxFrameBufferSize info.Details.MaxFrameBufferSize

Heatmaps interpret text using TeX markup


Behavior change

Starting in R2019a, heatmaps created with the heatmap function interpret text using TeX markup
instead of displaying the literal characters. If you want to use a TeX markup character in regular text,
such as an underscore (_), then insert a backslash (\) before the character you want to include. The
backslash is the TeX escape character. For more information on using TeX markup, see the
Interpreter property of the text object.

10-24
App Building

App Building

uiimage Function: Display an icon, logo, or picture in apps and on the


App Designer canvas
To display a picture, icon, or logo in your app, call the uiimage function programmatically or, in App
Designer, drag and drop an image component from the Component Library onto the canvas.

Image components are supported only in App Designer apps and in figures created with the
uifigure function.

uitable Function: Sort tables interactively when using table arrays


To create tables that can be sorted interactively, use table arrays and configure the
ColumnSortable property of the Table object. Use the DisplayData property and a
DisplayDataChangedFcn callback if you want to update your visualizations based on how a user
sorts a table containing table data.

Auto Resize: Automatically resize components when an app is made


smaller
When a parent container is resized smaller than its initial size, AutoResizeChildren now reduces
the white space between components and shrinks the components themselves to maintain usability.
For more information, see Managing Resizable Apps in App Designer.

Scrolling Grids: Create apps with scrollable grids


Enable interactive scrolling in your grid layout manager by setting the Scrollable property of the
grid to 'on'. See uigridlayout for more information.

App Designer: Create apps that automatically reflow content based on


device size
Create 2-panel or 3-panel preconfigured apps that automatically resize and reflow content based on
screen size, screen orientation, and platform. Use apps with auto-reflow if you expect to run or share
your apps across multiple environments or desktop resolutions. For more information, see Apps with
Auto-Reflow.

App Designer: Add and configure a grid layout manager on the App
Designer canvas
Structure the layout of your app by dragging a grid layout manager from the Component Library

onto the canvas. To configure the grid layout in Design View, select the icon from the upper-left
hand corner of the grid, or right-click and select Configure grid layout. Then, select a row or
column to edit. For more information, see the uigridlayout function or GridLayout
Properties.

10-25
R2019a

Grid layout managers are supported only in App Designer apps or in figures created with the
uifigure function.

App Designer: Rearrange the order of callbacks


To rearrange the order of callbacks, go to the Code Browser, select the callback you wish to move,
and then drag the callback into a new position in the list. This also repositions the callback in the
editor.

App Designer: Create new apps using App Designer Start Page
options
From the App Designer Start Page you can now do the following.

• Create a new blank app or a new responsive app with auto-reflow.


• Start a tutorial or access featured content from the top banner.
• View a list of your recent apps.
• Open apps from a file path.
• Select an example from the Getting Started or Programming Tasks example sections.

The Start Page appears when you launch App Designer. Once you are in the design environment, you
can get back to the Start Page by selecting the New icon from the Designer toolstrip.

App Designer: Control font, code, and autosave settings using


MATLAB Preferences
Control these settings through the Preferences dialog box

• Autocoding for patterns like parentheses, block endings, and comment wrapping
• Keyboard preferences for automatic code suggestions and completions
• Autosave preferences upon clicking away from a file
• Font size preference for App Designer Code View

Changes to the autosave and font size preferences apply to only the App Designer Editor. When you
set the autocoding or keyboard preferences, the change applies to the MATLAB Editor and to App
Designer.

App Designer: Access context-sensitive help in Code View


To open the documentation for a component, function, or callback in your code, highlight the element
and then press F1, or right-click and choose help for the code element you selected.

App Designer: Zoom in App Designer


Hold Ctrl and move the scroll wheel in the App Designer window to zoom in or out. To return to the
default scale, press Ctrl+0.

10-26
App Building

Graphics Support: Explore data using axes toolbar and data tips in
apps created with the uifigure function
Use the axes toolbar and data tips to explore plotted data interactively in App Designer apps and in
figures created with the uifigure function. The axes toolbar and data tips are on by default for
axes and uiaxes objects in a uifigure.

Compatibility Considerations
• Axes toolbar — In previous releases, the axes toolbar was not enabled for axes or uiaxes objects
in a uifigure object. Now, it is enabled by default. You can turn it off by setting the Visible
property of the AxesToolbar object to 'off'. For more information, see AxesToolbar
Properties.
• Data tips — In previous releases, data tips were not enabled for axes or uiaxes objects in a
uifigure object. Now, to control whether the axes interactions are enabled, use the
disableDefaultInteractivity and enableDefaultInteractivity functions. For example,

uf = uifigure;
ax = axes(uf);
plot(ax,rand(5))
disableDefaultInteractivity(ax)

Deployed Web Apps: Share resizeable apps or create apps that open
web pages
In deployed web apps you can now do the following:

• Interactively resize your web app.


• Program your web app to open another URL using the web function.

For information about other new features of deployed web apps, see Release Notes (MATLAB
Compiler).

MATLAB Online: Create and edit App Designer apps using MATLAB
Online
Create or edit apps in MATLAB Online using the App Designer development environment (supported
only for Google Chrome browsers).

App Testing Framework: Perform hover gesture on axes, UI axes, and


UI figures
The matlab.uitest.TestCase.hover method enables you to perform hover gestures in tests on
axes, UI axes, and UI figure objects. For more information, see the hover reference page.

10-27
R2019a

App Testing Framework: Perform press gesture on axes, UI axes, and


UI figures
The matlab.uitest.TestCase.press method enables you to perform press gestures in tests on
UI axes and UI figure objects. For more information, see the press reference page.

App Testing Framework: Perform type gesture on date picker objects


The matlab.uitest.TestCase.type method enables you to perform type gestures on date picker
objects. For more information, see the type reference page.

Functionality Being Removed or Changed


javacomponent function and JavaFrame property will be removed in a future release
Warns

The undocumented javacomponent function and JavaFrame property will be removed in a future
release. The JavaFrame property still runs, but returns a warning. The javacomponent function
still runs, without warning, but will begin to warn in an upcoming release. Users are encouraged to
update their code to use documented alternatives. For a list of documented functionality you can use
instead, see Java Swing Alternatives for MATLAB Apps on mathworks.com.

Support for running deployed web apps in Internet Explorer will be removed in a future
release
Still runs

Support for running deployed web apps in Internet Explorer will be removed in a future release. Use
the current versions of Google Chrome (recommended), Safari, Firefox, or Microsoft Edge to run
deployed web apps instead.

10-28
Performance

Performance

MATLAB and Simulink startup on macOS platforms


To prevent performance regression at startup for MATLAB and Simulink on macOS platforms,
MathWorks recommends using MATLAB R2018b Update 4 or later with macOS 10.13.6 Update or
later.

sortrows Function: Sort rows of large matrices faster


For large matrices, you can now sort rows faster using the sortrows function.

For example, on a test system, this code runs faster in R2019a than in previous releases.

A = repmat(eye(200),500,1);
sortrows(A)

uitable Function: Faster performance using table arrays


Tables created with the uitable function and with data specified as a table array have better
rendering performance and higher frame rates while scrolling. Tables that use table arrays render
up to 40% faster, and interaction performance (like scrolling) is up to 75% faster. For example, on a
test system, this code renders the tables faster in R2019a than in previous releases.

rows = 10000;
columns = 25;
data = array2table(randi(30, [rows, columns]));
fig = uifigure;
tbl = uitable(fig, 'Data', data);

For more information about using table arrays in Table UI components, see Table Array Data Types
in App Designer Apps.

10-29
R2019a

Software Development Tools

checkcode Function: Get the modified cyclomatic complexity of


functions
Use the checkcode function with the 'modcyc' option to get the modified cyclomatic complexity of
each function in a file. The modified cyclomatic complexity for a function is equal to the McCabe
complexity except for one difference. McCabe complexity counts each individual case within a
switch statement as 1, while modified cyclomatic complexity counts the entire switch statement as
1. In general, switch statements are simpler than nested if-elseif-else statements and
therefore, the modified cyclomatic complexity is often considered a better measure of code
complexity.

Source Control Integration: Synchronise MATLAB Git status with


external Git clients
If you use an external Git client, MATLAB now listens to external changes to working copies of .git
folders and refreshes the file status if needed. MATLAB keeps the Git file status in sync when using
another Git client, both in the MATLAB current folder and in a project.

Unit Testing Framework: Display code coverage metrics in HTML


format
The matlab.unittest.plugins.codecoverage.CoverageReport class provides an HTML code
coverage report format to display code coverage metrics. Use this format with
matlab.unittest.plugins.CodeCoveragePlugin to produce the report.

Unit Testing Framework: Specify sources for collections of code


coverage data with runtests
The runtests function enables you to specify the source code files to include in the code coverage
report. Use the ReportCoveragefor name-value input to specify the files or folders containing
source files to include in the tests.

Unit Testing Framework: runperf collects more samples to achieve its


target margin of error
The default maximum number of sample measurements that runperf makes when running
performance measurements has increased to 256. Specify the number of sample measurements using
the matlab.perftest.TimeExperiment.limitingSamplingError method.

Unit Testing Framework: Return performance test results as


TimeResult arrays
The runperf function now returns a matlab.perftest.TimeResult array containing the results
of the specified performance tests. This class derives from the
matlab.unittest.measurement.MeasurementResult class, which is now an abstract class.

10-30
Software Development Tools

Unit Testing Framework: Load previously saved MeasurementResult


objects as DefaultMeasurementResult
MeasurementResult objects saved in previous releases are loaded as
matlab.unittest.measurement.DefaultMeasurementResult objects. This class is derived
from the MeasurementResult class.

Unit Testing Framework: Use


matlab.unittest.fixtures.Fixture.onFailure method only in subclasses
The onFailure method now has protected access. In previous releases, onFailure had public
access. This change better supports the use of onFailure to produce additional diagnostics in case
of a failure during fixture setup or teardown in classes derived from Fixture.

Unit Testing Framework: Compare tables that contain no rows


In previous releases, for tables that had no rows (that is, that had a first size dimension of zero), the
matlab.unittest.constraints.IsEqualTo constraint did not compare the table column
variables when determining equality. Now, IsEqualTo always compares the size and type of each
column variable.

For example, comparing these two tables fails now because the column variables are different types
(double and cell).

tc = matlab.unittest.TestCase.forInteractiveUse;
a = table(zeros(0,2));
b = table({});
tc.verifyEqual(a,b)

Verification failed.
---------------------
Framework Diagnostic:
---------------------
verifyEqual failed.
--> Path to failure: <Value>.Var1
--> Classes do not match.

Actual Class:
double
Expected Class:
cell

Actual double:
0×2 empty double matrix
Expected cell:
0×0 empty cell array

Actual Value:
0×1 empty table
Expected Value:
0×1 empty table

10-31
R2019a

Unit Testing Framework: Create test suite array from tests in project
The fromProject method enables you to create a test suite array from the files in a project that are
labeled with the Test classification. For more information, see the
matlab.unittest.TestSuite.fromProject reference page.

Unit Testing Framework: Run tests from files in project using runtests
or testsuite
Run test files from projects using the runtests or testsuite functions. The
IncludeReferenceProjects name-value pair argument enables you to include in the test suite
files from a project that are labeled with the Test classification.

Unit Testing Framework: Specify verbosity enumeration as a string or


character vector
You can specify the verbosity level argument for the following methods as a string scalar or character
vector that correspond to the matlab.unittest.Verbosity enumeration member name.

• matlab.unittest.TestCase.log
• matlab.unittest.TestRunner.withTextOutput
• matlab.unittest.plugins.TestRunProgressPlugin
• matlab.unittest.plugins.LoggingPlugin.withVerbosity
• matlab.unittest.plugins.DiagnosticsOutputPlugin

App Testing Framework: Perform hover gesture on axes, UI axes, and


UI figures
The matlab.uitest.TestCase.hover method enables you to perform hover gestures in tests on
axes, UI axes, and UI figure objects. For more information, see hover.

App Testing Framework: Perform press gesture on axes, UI axes, and


UI figures
The matlab.uitest.TestCase.press method enables you to perform press gestures in tests on
UI axes and UI figure objects. For more information, see press.

App Testing Framework: Perform type gesture on date picker objects


The matlab.uitest.TestCase.type method enables you to perform type gestures on date picker
objects. For more information, see type.

Mocking Framework: Create mocks for classes that use custom


metaclasses
The unit testing framework can now create mocks for classes that use custom metaclasses to define
custom class, property, method, and event attributes.

10-32
Software Development Tools

Mocking Framework: Create mocks for classes that use property


validation
The unit testing framework can now create mocks for classes that use property validation. For
information on property validation, see Validate Property Values.

Mocking Framework: Specify which methods to mock


When creating a mock object, you can control which methods are mocked in the test case. Use the
createMock method with the MockMethods name-value pair argument to specify the method to
mock. This feature enables tests to mock only those methods that are important to the test case,
which can improve performance when superclasses define many methods.

Functionality being removed or changed


matlab.unittest.fixtures.Fixture.onFailure method has protected access
Behavior change

In release R2019a, the onFailure method Access attribute is changed from public to protected.
This change restricts the use of onFailure to classes derived from Fixture.

matlab.unittest.constraints.IsEqualTo always compares table column variables


Behavior change

In release R2019a, the IsEqualTo constraint always compares the size and type of column variables.

10-33
R2019a

External Language Interfaces

C++: Use C++ classes from third-party libraries in MATLAB


If you have a library that exports C++ constructs, including classes, functions and enumerations,
then you can use this functionality directly in MATLAB. For more information, see C++ Libraries.

If you have a C shared library, then use the loadlibrary function as described in C Libraries.

Python: Version 3.7 support


MATLAB now supports CPython 3.7, in addition to existing support for 2.7, 3.5, and 3.6.

For more information, see Install Supported Python Implementation.

Compatibility Considerations
To start the MATLAB engine asynchronously from Python 3.7, use the (background=True) keyword
argument for matlab.engine.start_matlab. To call a MATLAB function asynchronously, use the
background=True keyword argument for matlab.engine.MatlabEngine. Do not use the async
argument for either function, since it is a keyword in Python 3.7. You also can use the background
argument for all supported versions of Python.

Python engine: Data type support


The Python engine now supports this functionality:

• Convert MATLAB strings to Python strings


• Pass function handles to Python with the feval command
• Pass MATLAB value objects as opaque objects

C++ MEX: Execute MEX function out of process


Run C++ MEX functions in processes that are separate from the MATLAB process. You can run
multiple MEX functions in the same process and can create multiple processes to execute MEX
functions. For more information, see Out-of-Process Execution of C++ MEX Functions.

MEX functions: Use customer version of Boost library


Although MATLAB builds with Boost library version 1.56.0, as of MATLAB R2018a, you can use any
Boost library version in a MEX function.

MATLAB Data Array: Support for row-major memory layout


Create a matlab::data::Array with data memory layout specified as column-major (default) or
row-major. For more information, see the memoryLayout parameter in createArrayFromBuffer.
To determine the memory layout for an existing matlab::data::Array, call getMemoryLayout.

10-34
External Language Interfaces

Compiler support changed for building MEX files and standalone


MATLAB engine and MAT-file applications
Support Compiler Platform
Added Intel Parallel Studio XE 2019 with Microsoft Visual Studio Windows
2015 and 2017 for C, C++, and Fortran
Added Intel Parallel Studio XE 2019 for Fortran macOS

To ensure continued support for building your MEX files, consider upgrading to another supported
compiler. For an up-to-date list of supported compilers, see Supported and Compatible Compilers.

10-35
R2019a

Hardware Support

MATLAB Support Package for Parrot Drones: Control Parrot Mambo


FPV drone from MATLAB and acquire sensor data
The MATLAB Support Package for Parrot® Drones is available from release R2019a onwards.

The support package includes functions to pilot a Parrot Mambo FPV drone by sending MATLAB
commands to control its direction, speed, and orientation. You can also read the flight navigation data
such as speed, height, and orientation using MATLAB commands.

Deploy Sense HAT functions on Raspberry Pi hardware


These Sense HAT functions from the MATLAB Support Package for Raspberry Pi Hardware are
enhanced to generate code: sensehat, readHumidity, readPressure, readTemperature,
readAngularVelocity, readAcceleration, readMagneticField, readJoystick,
displayImage, writePixel, and clearLEDMatrix. You can now deploy these functions on the
hardware.

Functionality being changed or removed


The i2cdev and spidev functions will be removed in a future release
Warns

Use device instead of i2cdev and spidev to connect to I2C or SPI devices on Arduino hardware.

The property Pins of servo object will be removed in a future release


Warns

Use the property Pin instead of Pins to get the pin number of the Arduino hardware and the
Adafruit Motor Shield V2 for Arduino hardware to which the servo motor is connected. For more
information, see Connection to servo motor on Arduino and Connection to servo motor on Adafruit
Motor Shield V2.

The class arduinoio.LibraryBase will be removed in a future release


Warns

Use the class matlabshared.addon.LibraryBase instead of arduinoio.LibraryBase for


deriving Arduino add-on libraries.

MATLAB support for Adafruit Bluefruit EZ-Link Shield and Programmer will be removed in a
future release
Warns

The support for Adafruit Bluefruit EZ-Link Shield and Programmer will be removed in a future
release

MATLAB support for Arduino hardware boards has been removed


Errors

These Arduino hardware boards are no longer supported:

10-36
Hardware Support

• Arduino Fio
• Arduino Mini
• Arduino Pro

10-37
11

R2018b

Version: 9.5

New Features

Bug Fixes

Compatibility Considerations
R2018b

Desktop
Live Editor: Organize live scripts using additional subheading styles
Format text in live scripts using the new Heading 2 and Heading 3 text styles. To apply a text style,
go to the Live Editor tab and in the Text section, select any of the options under the Text Style drop-
down.

For more information, see Format Files in the Live Editor.

Live Editor: Navigate within a live script using internal hyperlinks


Use internal hyperlinks to navigate to locations within a live script. To insert an internal hyperlink, go
to the Insert tab and click Hyperlink. Enter your display text, select Internal Hyperlink, and
then click anywhere in the document to select the target.

Live Editor: Filter table output interactively, and then add the
generated code to the live script
In the Live Editor, you can filter table data interactively. To filter data in a table, click the down arrow
to the right of a variable name in the table and select from the available filtering options.

To add the generated code to your live script, use the Update Code button below the table. Adding
the generated code to your live script ensures that the sorting is reproduced the next time you run
the live script.

Live Editor: Create new and open existing live scripts faster
New and existing live scripts open faster than in previous releases.

Live Editor: Change case of text or code


In the Live Editor, you can change the case of selected text or code from all uppercase to lowercase,
or vice versa. To change the case, select the text, right-click, and select Change Case. You also can

11-2
Desktop

press Ctrl+Shift+A. If the text contains both uppercase and lowercase text, MATLAB changes the
case to all uppercase.

In MATLAB Online, this feature also is available in the Editor.

Comparison Tool: Merge two versions of a live script or function


When comparing live scripts or live functions using the Comparison Tool, you can merge changes
from one file to the other. Merging changes can be useful when resolving conflicts between different
versions of a file.

To merge two live scripts or functions, go to the Live Editor tab and in the File section, click
Compare. A new window opens and displays the two files side by side. Select the Merge Mode
button to start the merge.

Use the button to replace content in the right pane with content from the left pane. The right pane
contains the merged result. To save the result, click Save Result.

For more information, see Compare and Merge Live Code.

Add-On Manager: Install and manage multiple versions of a custom


toolbox
You can install multiple versions of a custom toolbox in the Add-On Manager. Having multiple
versions of a custom toolbox installed is useful if you regularly use multiple versions and switch
between them.

To install an additional version of a custom toolbox without overwriting any of the other installed
versions, use the matlab.addons.install function and specify 'add' as the installation option.
For example, matlab.addons.install('C:\myAddons\GUI Layout Toolbox
2.1.2.mltbx','add').

To select which version of the toolbox is enabled, go to the Home tab and select Add-Ons >
Manage Add-Ons. Click the button to the right of the toolbox you want. Then in the Versions
menu, select from the available versions. Selecting a version enables that version and disables all
other installed versions of the toolbox. You also can use the matlab.addons.enableAddon function.

Add-On Manager: Save add-ons to new default location


MATLAB now saves add-ons to a new default location. The default location is platform-specific.

• Windows platforms — C:\Users\username\AppData\Roaming\MathWorks\MATLAB Add-


Ons.
• Linux platforms — ~/MATLAB Add-Ons.
• Mac platforms — ~/Library/Application Support/MathWorks/MATLAB Add-Ons.

For more information, see Manage Your Add-Ons.

11-3
R2018b

Documentation: View MATLAB documentation in Spanish


A subset of MATLAB documentation in Spanish is available on the web to licensed MATLAB users. For
more information, see Translated Documentation.

MATLAB Drive: Install and start MATLAB Drive Connector from inside
MATLAB
You can now install and start MATLAB Drive Connector from inside MATLAB. To install the Connector,
click the MATLAB Drive button in MATLAB.

If MATLAB Drive Connector is already installed, clicking the MATLAB Drive button starts the
Connector. If MATLAB Drive Connector is already running, clicking the MATLAB Drive button
changes your working folder to MATLAB Drive.

MATLAB Drive: Improved performance when syncing files in MATLAB


Drive Connector
Your files now sync faster in MATLAB Drive Connector.

MATLAB Drive: Share and collaborate in MATLAB Drive online


(December 2018)
• Share your folders with a view-only link and by inviting individuals with either view-only or edit
permissions. Invitations can be accepted or declined.
• After a folder is shared, you can manage the permissions of invited members, rescind invitations,
or send additional invitations at any time.
• Share your MATLAB Drive folders and collaborate with others using MATLAB Online.
• MATLAB Drive Connector automatically syncs shared folders to your desktop computer while
retaining proper access permissions to their contents.

Note If you shared folders in MATLAB Online prior to the release of the share feature in MATLAB
Drive, your existing shared folders will be synced to your desktop computer into a folder named
Shared.

MATLAB Drive: View shared status of files in MATLAB Drive Connector


(February 2019)
Files in shared folders now have a SHARED indicator in MATLAB Drive Connector Activity section.

11-4
Desktop

You cannot edit a SHARED file in a Can View folder - this is indicated by a padlock icon .

11-5
R2018b

Language and Programming

string Arrays: Use string arrays in MATLAB, Simulink, and Stateflow


Specify text as string arrays where you previously specified text as character vectors or cell arrays of
character vectors. Use string arrays for data, properties, and name-value pair arguments. Specify
strings using double quotes, just as you specify character vectors using single quotes.

For more information on string arrays, see Characters and Strings. For guidelines on accepting
strings in your own code, see Update Your Code to Accept Strings.

MathWorks encourages the use of string arrays. For backward compatibility, MathWorks products will
continue to support the use of character vectors and cell arrays of character vectors.

convertContainedStringsToChars Function: Convert string arrays at


any level of cell array or structure
To make your existing code accept string arrays, or cell arrays and structure arrays that contain
strings, use the convertContainedStringsToChars function on the entire input argument list.
For more information on accepting strings in your own code, see Update Your Code to Accept Strings.

Enumerations: Improved performance of set operations with


enumerations
When called with enumeration arrays, execution of set operation functions such as ismember is
faster.

WSDL Web Services Documents: Required Tools Update


As of MATLAB R2018b, the supported versions of the Oracle® Java JDK and the Apache CXF
programs that are required to use a WSDL Web service in MATLAB have changed.

For more informations, see Set Up WSDL Tools.

Compatibility Considerations
Download and install the JDK software from the Java SE Downloads Web page https://
www.oracle.com/technetwork/java/javase/downloads. Choose the Java SE Development Kit 8.

Download the latest version 3.2 release of the Apache CXF tool from https://cxf.apache.org/download.

Functionality being removed or changed


validateattributes check for 'finite' and 'nonnan' attributes
Behavior change in future release

In the validateattributes function, the 'finite' and 'nonnan' attributes no longer require
that the input passes an isnumeric check.

11-6
Language and Programming

Folders named resources will not be allowed on the MATLAB path


Still runs

In future releases, the resources folder will become a reserved folder, and folders with the name
resources will not be allowed on the MATLAB path. Currently, these folders are allowed on the
MATLAB path.

If a folder named resources is specified when calling the addpath, userpath, or pathdef
functions, MATLAB will return a warning and the folder will not be not added to the path.

Rename all folders on the path named resources.

11-7
R2018b

Mathematics

boundaryshape Function: Create a polyshape object from a 2-D


triangulation
You now can use the boundaryshape function to convert a 2-D triangulation object to a
polyshape object.

polyshape Objects: Specify when to keep collinear points when


creating a polyshape
When creating a polyshape object, collinear points are removed by default. These functions now
offer the option to keep collinear points as vertices of the returned polyshape using the name-value
pair 'KeepCollinearPoints'.

polyshape subtract
addboundary union
intersect xor
simplify

RandStream Objects: Generate random numbers using Threefry and


Philox algorithms
When creating a random stream with RandStream, you now can use the Threefry and Philox random
number generation algorithms.

GraphPlot Object: Customize node and edge labels with font


properties
GraphPlot objects have several new properties to enable customization of node and edge labels in
plots of directed or undirected graphs.

Property Description
NodeLabelColor Background color of label

EdgeLabelColor
NodeFontSize Font size for label

EdgeFontSize
NodeFontName Font for label

EdgeFontName
NodeFontAngle Normal or italic text

EdgeFontAngle

11-8
Mathematics

Property Description
NodeFontWeight Normal or bold text

EdgeFontWeight
Interpreter Interpretation of text characters in labels (none,
tex, or latex)
ArrowPosition Position of arrow on directed edges

Compatibility Considerations
The new GraphPlot property Interpreter has a default value of 'tex'. In previous releases,
graph node and edge labels displayed text as the literal characters instead of interpreting the text
using TeX markup. If you do not want node and edge labels to use TeX markup, then set the
Interpreter property to 'none'.

sinpi and cospi Functions: Compute the sine and cosine of multiples of
π
The sinpi and cospi functions compute the values of sin(πx) and cos(πx). The answers provided by
these functions are more accurate than answers provided by sin(pi*x) or cos(pi*x) because they
do not compute pi*x explicitly. This convention compensates for roundoff error in the floating-point
value of pi.

11-9
R2018b

Graphics
Axes Interactions: Explore data with panning, zooming, data tips, and
3-D rotation enabled by default
Interactively explore your data using axes interactions that are enabled by default. For example, you
can use the scroll-wheel to zoom into your data or hover over a data point to see a data tip. Also, you
can click and drag the axes to pan the axes (2-D view) or rotate the axes (3-D view). For more
information, see Interactively Explore Plotted Data.

Compatibility Considerations
In previous releases, none of the interactions were enabled by default. To control if the axes
interactions are enabled by default, use the disableDefaultInteractivity and
enableDefaultInteractivity functions.

Axes Toolbar: Access and customize a data exploration toolbar for


each Axes object
Axes have a toolbar that appears above the top-right corner for quick access to the data exploration
tools. The buttons available in the toolbar depend on the contents of the axes. The toolbar typically
includes buttons to brush data, add data tips, rotate the axes (3-D axes only), pan or zoom the data,
and restore the view.

You can customize the buttons available in the toolbar using the axtoolbar and axtoolbarbtn
functions.

Compatibility Considerations

In previous releases, the buttons that now appear in the axes toolbar appeared in the figure toolbar
instead. You can turn off the axes toolbar by setting the Visible property of the AxesToolbar
object to 'off'.
ax = gca;
ax.Toolbar.Visible = 'off';

You can restore the figure toolbar buttons using the addToolbarExplorationButtons command.

Geographic Plots: Create line, scatter, and point density plots on


interactive maps and control properties of a geographic axes
Create line, scatter, and point density plots on interactive maps and control properties of a
geographic axes. Use the geoplot, geoscatter, and geodensityplot functions to create these
plots. The geolimits function now works with any of these geographic plots, in addition to
geographic bubble charts. To change the basemap used by any of these geographic plots or charts,
use the new geobasemap function.

11-10
Graphics

stackedplot Function: Plot variables of a table or timetable for


comparison using a common x-axis
Plot the variables of a table or timetable. To ease visual comparison, the stackedplot function
provides a common x-axis and separate y-axes for the variables.

scatterhistogram Function: Visualize grouped data as a scatter plot


with marginal histograms
To create a scatter plot with marginal histograms, use the scatterhistogram function. To group
the data, you can use either the 'GroupVariable' name-value pair argument with tabular data or
the 'GroupData' name-value pair argument with arrays.

sgtitle Function: Create a title for a grid of subplots


You can add an overall title to a grid of subplots, in addition to adding a title to each individual
subplot. To add an overall title, use the sgtitle function.

xline and yline Functions: Add vertical or horizontal lines to a plot


To add vertical or horizontal lines to a plot, use the xline or yline functions, respectively. For
example, xline(3) plots a vertical line at x = 3.

11-11
R2018b

imtile Function: Combine multiple image frames into one rectangular


tiled image
To combine multiple image frames into one rectangular tiled image, use the imtile function.

Data Tips: Use TeX or LaTeX markup in data tips with improved visual
appearance
Data tips have an improved visual appearance with new text colors.

Also, data tips now display text characters using TeX markup by default. Control the interpretation of
the text characters using the Interpreter property of the data cursor mode object. Set the property

11-12
Graphics

value to 'tex' for TeX markup (default), 'latex' for LaTeX markup, or 'none' for literal
characters.

d = datacursormode;
d.Interpreter = 'latex';

Compatibility Considerations
In previous releases, data tips displayed text as the literal characters instead of interpreting the text
using TeX markup. If you do not want data tips to use TeX markup, then set the Interpreter
property to 'none'.

Functionality being removed or changed


legend function interprets argument as property name when property exists
Behavior change

Starting in R2018b, if you pass an argument to the legend function that matches the name of a
legend property, the function interprets the argument as the name of a name-value pair. In previous
releases, the legend function recognized name-value pairs only when the first argument was a cell
array.

As a result of this change, in most cases, it is unnecessary to specify the first argument as a cell array
when using name-value pairs. However, if you want a label in your legend that matches the name of a
legend property, such as Position or NumColumns, then you must specify all the labels in a cell
array. Otherwise, the legend function interprets the argument as a name-value pair instead of a
label.

Description Recommended Code


If you want a label in your legend that matches legend({'Label1','NumColumns','Label3','Label4'},'Num
the name of a legend property, such as
'NumColumns', then specify all the labels in a
cell array. If you specify 'NumColumns' outside
of a cell array, the legend function interprets it
as a name-value pair.
If none of your labels match the name of a legend legend('Label1','Label2','Label2')
property, then you do not need to use a cell array
around the labels.

alpha and shading set both FaceColor and FaceAlpha properties


Behavior change

When updating surface and patch objects, the alpha and shading functions sometimes set both the
FaceColor and FaceAlpha properties. These functions set both properties in cases where setting
just one property results in a rendering issue. No updates to your code are required.

In previous releases, the alpha function set only the FaceAlpha property. Similarly, the shading
function set only the FaceColor property.

11-13
R2018b

Data Import and Export

Import Tool: Generate improved code when importing from


spreadsheets
The Import Tool now offers improved code generation functionality for importing spreadsheets across
platforms. For example, you can import datetimes on Mac and Linux and generate code that is easy to
read. For more information, see Read Spreadsheet Data Using Import Tool.

Compatibility Considerations
For more information, see “Import Tool handling of spreadsheet dates and times and fields that are
empty, unimportable, or error causing” on page 11-15.

Web-Based Data: Read from web-based data sources like Amazon Web
Services and Azure Blob Storage using readtable,
detectImportOptions, spreadsheetDatastore, imread, and imfinfo
You can access tabular data and images from files stored in remote locations (Amazon S3, Windows
Azure Blob Service, and HDFS) using these functions:

• readtable
• detectImportOptions
• spreadsheetDatastore
• imread
• imfinfo

When reading data from remote locations, you must specify the full path using a uniform resource
locator (URL). For example, read a csv file from Amazon S3 cloud:

T = readtable('s3://bucketname/path_to_file/my_text_file.csv');

For more information on setting up MATLAB to access your online storage service, see Work with
Remote Data.

write Function: Write tall arrays in a variety of formats to local or


remote locations
The functionality of write is expanded to support additional formats and storage locations:

• Output formats include .txt, .csv, .xls, and more.


• Name-value pairs to control format-specific options, such as WriteVariableNames and
Delimiter.
• Extended support for writing .seq and .mat formats to all supported file systems.
• Write data to remote locations in Amazon S3 or Windows Azure Blob Storage (WASBS).

11-14
Data Import and Export

stlread and stlwrite Functions: Read from and write to STL


(Stereolithography) files for triangulations
The stlread function enables you to read triangulation information from an STL file to create a
triangulation object. You also can write a triangulation object or a 2-D
delaunayTriangulation object to a binary STL file with stlwrite.

TabularTextDatastore Object: Import data containing dates and times


from non-English locales
The TabularTextDatastore object now supports import of date and time data from non-English
locales. For example, to create a datastore for reading files that contain German date and time data,
set the DatetimeLocale parameter to 'de_DE'.
ds = tabularTextDatastore('myDataFile.csv','DatetimeLocale','de_DE')

readtable and writetable Functions: Read or write spreadsheet files


without initiating Microsoft Excel for Windows on Windows platforms
On Windows platforms, you can choose not to open an instance of Microsoft Excel when reading or
writing data from spreadsheet files. Set the 'UseExcel' parameter to one of these values:

• true — Open an instance of Microsoft Excel to read (or write) the file. This setting is the default
for Windows systems with Excel installed.
• false — Do not open an instance of Microsoft Excel to read (or write) the file. Using this setting
might cause the data to be written differently for files with live updates like formula evaluation or
plugins.

For more information, see readtable and writetable.

readtable Function: Manage the import of empty fields using import


options
You can manage empty fields in tabular data by using readtable along with import options. Use the
EmptyFieldRule of import options object to specify how readtable handles empty fields. For more
information, see setvaropts.

Scientific File Format Libraries: CFITSIO Library upgraded to version


3.420
The CFITSIO library is upgraded to version 3.420.

Functionality being removed or changed


Import Tool handling of spreadsheet dates and times and fields that are empty,
unimportable, or error causing
Behavior change

Starting in R2018b, the Import Tool app has improved functionality for importing data from
spreadsheet files. The changes to imported data are minimal and are limited to uncommon cases:

11-15
R2018b

• Empty or unimportable cells in spreadsheets:

• The value you use to replace empty cells and unimportable cells must be the same. Previously,
Import Tool allowed for different values for empty cells and unimportable cells.
• Previously, Import Tool allowed you to specify a target string for cells that are unimportable.
This feature is no longer supported.
• Date and time data in spreadsheets:

• Import date and time data as MATLAB datetime arrays on all platforms.
• Import numbers as date and times on all platforms.
• Import Excel dates as numbers on all platforms.
• When running the Import Tool app in MATLAB on a Windows machine, cells in Excel spreadsheets
with error conditions are no longer displayed.

Basic parameter of the readtable function (Not Recommended)


Still runs

The Basic parameter of the readtable function is not recommended. Use the parameter name
UseExcel instead. There are no plans to remove the Basic parameter at this time.

UseExcel parameter of the readtable and writetable functions


Behavior change in future release

In future releases, the default value of the UseExcel parameter will be changed to false. The
current default setting for UseExcel on Windows systems with Excel installed is true.

This table shows the typical usage of readtable and how to update your code to preserve the
current behavior in future releases.

Code Use this instead


Behavior
(R2018b and earlier) (Future releases)
T = readtable(filename) Start an instance of Microsoft
T = readtable(filename,'UseExcel',true)
Excel when reading the file.

For more information, see readtable and writetable.

Output from the audioread function for A-law or mu-law wave files
Behavior change

When reading in native mode, the audioread function returns data from A-law or mu-law wave files
as int16.

Previously, audioread returned data from A-law or mu-law wave files as int8.

Transparency output from the imread function


Behavior change

The imread function returns transparency information for indexed PNG images. For example,
reading a png file returns a nonempty transparency array alpha:

[img,map,alpha] = imread('myIndexedImage.png');
whos alpha

11-16
Data Import and Export

Name Size Bytes Class Attributes

alpha 50x120 48000 double

Previously, the imread function did not return transparency information for indexed PNG images. For
example, previously reading a png file returned an empty transparency output alpha:

[img,map,alpha] = imread('myIndexedImage.png');
whos alpha

Name Size Bytes Class Attributes

alpha 0x0 0 double

11-17
R2018b

Data Analysis

Vector Dimension Argument: Operate on multiple dimensions at a


time for selected reduction functions
These functions now accept a vector dimension argument to specify multiple operating dimensions at
a time, as well as the option 'all' to specify all dimensions of an array.

all min
any mode
bounds prod
max std
mean sum
median var

For example, sum(A,'all') sums all the elements in a matrix A, and is equivalent to sum(A,[1
2]).

grouptransform Function: Transform table or timetable data by groups


You can use the grouptransform function to perform group computations, such as normalization or
filling missing data on table and timetable variables. For example, g =
grouptransform(T,'School','norm') normalizes the data in a table T by school using the
vector 2-norm.

groupsummary Function: Perform group summary computations on


matrices
You now can group by matrix rows to perform summary computations using the groupsummary
function.

tall Arrays: Write custom algorithms to operate on tall arrays


The functions matlab.tall.transform and matlab.tall.reduce enable you to write custom
algorithms to execute on tall arrays. These functions enable you to implement a range of
parallelizable algorithms. matlab.tall.transform applies a single function to each block of a tall
array, while matlab.tall.reduce is similar to MapReduce, where two functions are applied to a
tall array, with the output of the first function being fed as input to the second function.

matlab.tall.transform and matlab.tall.reduce provide the flexibility to implement functions


that otherwise do not currently support tall arrays. For more information, see Develop Custom Tall
Array Algorithms.

11-18
Data Analysis

tall Arrays: Operate on tall arrays with more functions, including


conv2, wordcloud, and groupsummary
The functions listed in this table add support for tall arrays as inputs. For a complete list of supported
functions, type methods tall. For more information on usage and limitations, see the Extended
Capabilities section at the bottom of the reference pages.

conv2 islocalmin
convn rmoutliers
corrcoef vecnorm
groupsummary wordcloud
islocalmax

In addition, some functions have expanded support for tall arrays. This expanded support removes
some limitations of using these functions with tall arrays.

Functions Added Support


join Joining two tall inputs (tall tables and/or tall
timetables) is now supported.

Previously, one of the inputs was required to be


an in-memory table or timetable.
sort These functions now support multiple output
arguments. The extra outputs return indices that
sortrows are relevant to the operation or that describe the
location of interesting elements.
topkrows
Previously, these functions did not support
unique multiple outputs for tall arrays.
mean Calculating the mean of datetime values is now
supported.

Previously, this function did not support tall


arrays with an underlying data type of datetime.

rmoutliers Function: Remove outliers in an array, table, or timetable


The rmoutliers function detects and removes outlier data in an array, table, or timetable.

islocalmin and islocalmax Functions: Specify a range of data for


prominence computation
The 'ProminenceWindow' name-value pair for the islocalmin and islocalmax functions enables
you to specify a local neighborhood about each element in the input data when computing the
corresponding prominence.

11-19
R2018b

Table and Timetable Metadata: Store custom metadata for each


variable
You can store custom metadata for variables of a table or timetable using its
Properties.CustomProperties object. For more information, see the Custom Metadata sections
of table and timetable.

timetable Data Type: Save memory when storing row times with
regular time steps
If you create a timetable with regular time steps, then it stores the row times using less memory than
in previous releases. You can create a regular timetable using the array2timetable, retime,
synchronize, table2timetable, or timetable functions.

A timetable stores the start time, time step, and sample rate as properties. For more information, see
the Row Times Metadata section of timetable.

timerange Function: Specify unit of time to define time range


When you specify the beginning and end of a time range using datetime values, you also can specify
the date or time component used to define the endpoints. For example, S =
timerange('2018-9-30','quarters') creates a time range spanning all dates in the third
quarter of 2018, since September 30 is in the third quarter. For more information, see timerange.

convertvars Function: Convert table or timetable variables to


specified data type
You can specify variables of a table or timetable, and convert them to a different data type, using the
convertvars function.

table, timetable, and addvars Functions: Use single quotes for input
names, not double-quoted strings
When creating or updating a table or timetable using the table, timetable, or addvars functions,
use single quotes for input names (such as 'Size', 'VariableNames', 'After', or 'TimeStep')
to avoid confusion with variable inputs. Variables and input values can use double-quoted strings. For
example:
T = table("some text",'VariableNames',["X"]);

Functionality Being Removed or Changed


'SamplingRate' is not recommended
Still runs

The 'SamplingRate' name-value pair argument is not recommended. Use 'SampleRate' instead.
The corresponding timetable property is also named SampleRate.

For backward compatibility, you still can specify 'SamplingRate' as the name of the name-value
pair. However, the value is assigned to the SampleRate property.

11-20
Data Analysis

This change in behavior affects the timetable functions shown in the table.

Function
array2timetable
retime
synchronize
table2timetable
timetable

Default random number generator change for tallrng


Behavior change in future release

Starting in R2019a, the default random number generator for tallrng will change to threefry.
This generator offers performance enhancements for parallel calculations over the current default. In
releases up to R2018b, the default random number generator for tallrng is combRecursive.

With a different default generator, MATLAB will generate different sequences of random numbers by
default in the context of tall arrays. However, the statistics of these calculations will remain
unaffected. Therefore, you should update any code that relies on the specific random numbers being
generated. However, most calculations on the random numbers should be unaffected.

To set the generator to the settings used by default in R2018b and earlier releases, use the command:

tallrng(0,'combRecursive')

11-21
R2018b

App Building

App Designer: Add and configure date selection components on the


App Designer canvas
Drag and drop date picker components from the Component Library onto the canvas.

App Designer: Unified property inspector in Design View and Code


View
The Component Properties pane in Design View now provides the full list of properties and the
same interactive controls as Code View does.

App Designer: Expand and collapse sections of code in Code View


App Designer provides code folding capabilities in Code View. You can expand sections of code that
you are working on and collapse other sections to navigate your code more easily.

App Designer: Export apps as code files


Export apps you create in App Designer as (.m) program files. Select Save > Export to .m File in the
App Designer toolstrip.

Exporting an app as a program file enables you to change it outside of App Designer. However, there
is no option for importing your changes back into App Designer.

App Designer: Locate errors and warnings in your code with the Code
Analyzer message bar
App Designer now provides the same Code Analyzer messaging system as the MATLAB Editor does.

App Designer: Program apps faster using improved code suggestions


and completions
As you code your app, App Designer displays the same contextual hints for arguments, property
values, and syntaxes as the Live Editor does.

App Designer: Control App Designer Code View settings using MATLAB
preferences
Control the following settings for App Designer Code View by setting MATLAB preferences:

• Highlight current line


• Show line number
• MATLAB syntax highlighting colors

When you set any of these preferences, the change applies to the MATLAB Editor and App Designer.

11-22
App Building

uigridlayout Function: Configure app layouts using a grid layout


manager
Use the uigridlayout function to create grid layout managers in your apps. When you use a grid
layout manager, you position UI components along the rows and columns of an invisible grid that
spans the entire app window or a container in the window. Using rows and columns to position
components is easier to manage than setting pixel values in Position vectors. For resizable apps,
grid layouts provide more flexibility than the automatic resize behavior in App Designer, and they are
easier to code than SizeChangedFcn callbacks. For more information, see Using Grid Layout
Managers.

Grid layout managers are only available in apps created with the uifigure function.

Scrolling Containers: Enable scrolling for figure, panel, tab, and


button group containers
Enable scrolling within a figure or any child container by setting the Scrollable property to 'on'.
To scroll to a location within the container programmatically, call the scroll function.

Scrolling works only in App Designer apps, in figures created with the uifigure function, or in child
containers within those figures.

Figure Interactions: Create apps with custom mouse and keyboard


interactions using figures created with the uifigure function
Create apps that respond to custom mouse and keyboard interactions. The following properties are
available in App Designer and in figures created with the uifigure function.

Category Properties
Figure Data SelectionType, CurrentPoint, CurrentCharacter
Mouse Callbacks ButtonDownFcn, WindowButtonDownFcn, WindowButtonUpFcn,
WindowButtonMotionFcn, WindowScrollWheelFcn
Keyboard Callbacks KeyPressFcn, KeyReleaseFcn, WindowKeyPressFcn,
WindowKeyReleaseFcn

Figures created with the figure function continue to support these properties as they have in the
past.

Graphics Support: Integrate plots into an app using the axes,


polaraxes, and geoaxes functions
Display more types of plots in App Designer apps and in figures created with the uifigure function.
The expanded list of plots includes subplots, polar plots, and geographic plots. For more information,
see Displaying Graphics in App Designer.

Tooltips: Create custom tooltips for UI components in apps


Set the Tooltip property on a UI component to display a tooltip when the user hovers the mouse
over the component at run time. Tooltips display even when the components are disabled.

11-23
R2018b

The Tooltip property is available for UI components in App Designer apps and in figures created
with the uifigure function.

If you are creating an app using GUIDE or the figure function, use the Tooltip property instead of
the TooltipString property on UIControl, Table, Tab, PushTool, and ToggleTool UI
components. For details, see “TooltipString property is not recommended” on page 11-24.

Deployed Web Apps: Access files in deployed web apps using the
uigetfile and uiputfile functions
Call uigetfile in a web app to enable users to select files on their local systems. Users can select
files by dropping them onto the app or by selecting them in a file browser.

Call uiputfile to enable users to specify file names for saving files.

For information about other new features of deployed web apps, see Release Notes (MATLAB
Compiler).

Running Apps in Browsers: Use most modern browsers to run apps in


MATLAB Online or as deployed web apps
Run apps in MATLAB Online, and run deployed web apps using Safari, Firefox, and Microsoft Edge in
addition to Google Chrome and Internet Explorer. Use the current versions of these browsers for best
results. For the best overall experience, use Google Chrome.

For information about MATLAB Online system requirements, see https://www.mathworks.com/


support/requirements/browser-requirements.html.

For information about other new features of deployed web apps, see Release Notes (MATLAB
Compiler).

uisetcolor Function: Select custom colors interactively


Select custom colors using an improved interactive color picker in the uisetcolor dialog box. Make
your selection by clicking within a color gradient. You can select colors as HSV values in addition to
the RGB and hexadecimal options that have been available in previous releases.

Functionality Being Removed or Changed


TooltipString property is not recommended
Still runs

The TooltipString property for the UIControl, Table, Tab, PushTool, and ToggleTool UI
component objects is not recommended. Use the new Tooltip property to display a tooltip instead.

The TooltipString property is no longer listed when you call the get, set, or properties
functions to list the properties of the object. There is no plan at this time to remove support for
getting or setting the value of the TooltipString property. However, partially specifying the
TooltipString property name might produce errors. To prevent the error, specify the full name of
the TooltipString property, or use the Tooltip property. Both property names correspond to the
same value.

11-24
Performance

Performance

Startup: Increased speed of MATLAB startup


MATLAB starts faster because of continued infrastructure improvements and optimizations.

Execution Engine: Index into large arrays with improved performance


when using the colon operator
Now colon indexing into large, numeric arrays is faster.

Execution Engine: Faster calls to built-in functions


Calls to built-in functions are faster due to reduced overhead.

Live Editor: Create new and open existing live scripts faster
New and existing live scripts open faster than in previous releases.

Enumerations: Improved set function performance with enumerations


When called with enumeration arrays, execution of set operation functions such as ismember is
faster.

Building Apps: Faster canvas interactions in App Designer


Many common tasks in the App Designer canvas, such as copying, pasting, and deleting components
are 90% faster.

Running Apps: Faster startup time for apps


Startup time is 10% to 30% faster for apps created in App Designer and apps created
programmatically using the uifigure function. The time savings become more noticeable as the
number of components in your app increases.

sort Function: Sort matrices and arrays faster


The sort function is now faster when sorting numeric matrices or multidimensional arrays.

11-25
R2018b

Hardware Support
MATLAB Online: Communicate with Raspberry Pi hardware board from
MATLAB Online
You now can connect to and control Raspberry Pi hardware boards remotely from MATLAB Online.
Raspberry Pi 2 Model B and Raspberry Pi 3 Model B are supported. Install the MATLAB package onto
Raspberry Pi, use raspilist in MATLAB Online to discover available boards, and use raspi to
create a connection. The functions in the MATLAB Support Package for Raspberry Pi Hardware
(except openShell and putFile) are available in MATLAB Online. For more information on how to
communicate with your Raspberry Pi in MATLAB Online, see Connect to Raspberry Pi Hardware
Board in MATLAB Online (MATLAB Support Package for Raspberry Pi Hardware).

Deploy a MATLAB function on Raspberry Pi hardware


From R2018b, MATLAB Support Package for Raspberry Pi Hardware enables you to deploy your
MATLAB function as a standalone executable on the Raspberry Pi hardware. For deploying the
function, use the targetHardware command to create a Raspberry Pi configuration object, and then
use the deploy command to deploy the function on the Raspberry Pi hardware.

To use this feature, you must install MATLAB Coder in your computer.

To support deployment, the Raspberry Pi functions are enhanced to generate code. Some functions
are listed here. For more details, see MATLAB Support Package for Raspberry Pi Hardware.

Peripheral Function
Raspi raspi
LEDs writeLED
GPIO Pins configurePin, readDigitalPin, and
writeDigitalPin
I2C Interface i2cdev, read, write, readRegister, and
writeRegister
SPI Interface spidev and writeRead
Serial Port serialdev, read, and write
Servo servo and writePosition
Linux system
Camera Board cameraboard, snapshot, record, and stop
Web Camera webcam and snapshot
Pulse Width Modulation writePWMFrequency, writePWMDutyCycle,
and writePWMVoltage

iOS and Android Sensors: Acquire sensor data when your device does
not have network access
You can acquire sensor data locally on your Android® or Apple iOS device, with or without a network
connection. This method is an alternative method of collecting the sensor data instead of streaming it

11-26
Hardware Support

from the device to your computer running MATLAB. It is especially useful if you want to collect
sensor data while your device does not have a network connection.

To use this method of acquiring sensor data, you log sensor data locally on your mobile device using
MATLAB Mobile, and then upload the files to MATLAB Drive once you are connected. To use MATLAB
Drive, you must log into your MathWorks account. Alternatively, you can transfer the log files
manually using a USB cable. Once you have the sensor data on your computer running MATLAB, you
use the MATLAB Support Package for Android Sensors or the MATLAB Support Package for Apple
iOS Sensors to view and analyze the data.

For more information, see the help screens in MATLAB Mobile or the MATLAB Support Package for
Android Sensors or MATLAB Support Package for Apple iOS Sensors documentation.

iOS and Android Sensors: Upload sensor logs from the device to
MATLAB Drive
You can acquire sensor data locally on your Android or Apple iOS device, with or without a network
connection. You can then upload the files to MATLAB Drive when you are connected. To use MATLAB
Drive, you must log into your MathWorks account.

You can have the log files automatically upload to MATLAB Drive when you have a network
connection, or choose to upload them from the Sensor Logs screen in MATLAB Mobile any time. Go
to Settings > Configure > MATLAB Drive Upload > Auto Upload to select your preference.

For more information, see the help screens in MATLAB Mobile or the MATLAB Support Package for
Android Sensors or MATLAB Support Package for Apple iOS Sensors documentation.

11-27
R2018b

Advanced Software Development

Tab Completion: Validate function signature file with


validateFunctionSignaturesJSON function
Use the validateFunctionSignaturesJSON function to validate the JSON-formatted file that
contains information about your function signatures. For more information, see
validateFunctionSignaturesJSON.

MATLAB uses the information in functionSignatures.json to improve interactive features, such


as tab completion and function hints. For information on creating a functionSignatures.json
file, see Customize Code Suggestions and Completions.

Tab Completion: JSON parser for functionSignatures.json upgrade


The JSON file parser that MATLAB uses to read functionSignatures.json files is upgraded for
R2018b.

Compatibility Considerations
The updated parser has stricter validation for JSON files. Before R2018b, a
functionSignatures.json file could have syntax errors that were undetected by the JSON parser.
For these newly detected errors, MATLAB displays an error message in the Command Window when
it reads the file.

Correct any syntax errors in the JSON file. Best practice is to validate functionSignatures.json
files with the validateFunctionSignaturesJSON function.

Java SE 8: MATLAB support, providing improved security and access to


new Java features
Java interface supports JRE version Java 1.8.0_152. For more information, see MATLAB Supported
Interfaces to Other Languages.

Python Interface: Pass multidimensional numeric or logical arrays


between MATLAB and Python
MATLAB auto converts numeric and logical array data input to a Python function to a Python
memoryview object. For more information, see Passing Matrices and Multidimensional Arrays.

C++ MEX API: Call MATLAB asynchronously from within a MEX file
using the C++ API
Use the asynchronous C++ MEX API to call MATLAB functions from user application threads in MEX
functions. Calls to MATLAB from user application threads are queued and executed in sequence with
other MATLAB commands. For more information, see Call MATLAB from Separate Threads in MEX
Function.

11-28
Advanced Software Development

Unit Testing Framework: Run tests in parallel with more plugins and
more intelligent scheduling
R2018b includes refinements to the testing framework parallel scheduling algorithm. These
enhancements improve the overall performance of the 'UseParallel' option in runtests and the
TestRunner.runInParallel method.

Also, the following plugins now can run tests in parallel:

• CodeCoveragePlugin with Cobertura format


• TestReportPlugin
• XMLPlugin.producingJUnitFormat

Unit Testing Framework: Use external parameters in parameterized


test
You can inject variable inputs into your parameterized test. For example, you can specify that a test
uses input data from a file instead of the data hard-coded within a test. To define external
parameters, use the fromData method of the matlab.unittest.parameters.Parameter class.
Then, specify that your parameterized test use the external parameters using the
'ExternalParameters' option to TestSuite creation methods. TestSuite creation methods
include fromClass, fromFile, fromFolder, fromMethod, fromName, and fromPackage.

For more information, see Use External Parameters in Parameterized Test.

Unit Testing Framework: Sort test suite based on shared fixtures


To reduce shared fixture setup and teardown operations, sort test suite elements so that elements
that require the same shared fixture setup are adjacent. To sort an existing test suite, use the
sortByFixtures method of matlab.unittest.TestSuite. The testsuite function
automatically creates a test suite that is sorted based on shared fixtures. However, if you concatenate
test suites after creating them, call the sortByFixtures method to reorder the suite. For more
information, see matlab.unittest.TestSuite.sortByFixtures.

Unit Testing Framework: Explicitly control output display detail and


logged diagnostic level
From the Run Tests section in the Editor, you can control the amount of detail displayed for a test
run. For example, to display the most information, select Verbose from the Output Detail test option
under the Run Tests icon. To suppress output, select None.

You can control which logged diagnostics are displayed by selecting a value from the Logging Level
test option under the Run Tests icon. Logged diagnostics are diagnostics that you supply in your test
code with a call to the TestCase.log method. MATLAB reports logged diagnostics at the specified
logging level and lower. For example, to exclude diagnostics logged at detailed or verbose levels,
select Concise.

You can also control the output detail and logged diagnostic level programmatically using the
'OutputDetail' and 'LoggingLevel' name-value pairs in these features:

11-29
R2018b

• runtests function
• TestRunner.withTextOutput method
• DiagnosticsOutputPlugin class
• DiagnosticsRecordingPlugin class
• TAPPlugin class
• XMLPlugin class ('OutputDetail' only)
• TestReportPlugin class ('LoggingLevel' only)

The matlab.unittest.Verbosity enumeration now contains the Verbosity.None member. Use


this verbosity level to indicate a detail level that includes no information. This enumeration member
is accepted anywhere that accepts a Verbosity value, except for the
matlab.unittest.TestCase.log and matlab.unittest.fixtures.Fixture.log methods.
These methods direct the framework to log diagnostics, not to display them.

Compatibility Considerations
Before R2018b, the 'Verbosity' name-value pair controlled both the output detail and the logged
diagnostic level, and the 'ExcludingLoggedDiagnostics' name-value pair determined whether
plugins recorded logged diagnostics.

These name-value pairs are supported, but are not recommended. Use 'LoggingLevel' and
'OutputDetail' instead. Replace instances of 'ExcludingLoggedDiagnostics' and
'Verbosity' in the following plugins:

• runtests function ('Verbosity' only)


• matlab.unittest.TestRunner.withTextOutput method ('Verbosity' only)
• matlab.unittest.plugins.DiagnosticsRecordingPlugin class
• matlab.unittest.plugins.TAPPlugin class
• matlab.unittest.plugins.TestReportPlugin class

Unit Testing Framework: Configure detail level of output diagnostics


To configure the amount of detail included in an output stream for diagnostics from passing, failing,
and logging events, add the DiagnosticsOutputPlugin to a TestRunner instance. For example,
you can specify that Command Window output includes passing diagnostics at a verbose detail level
or you can suppress the display of diagnostics.

For more information, see the matlab.unittest.plugins.DiagnosticsOutputPlugin class.

Unit Testing Framework: Compare values faster when using


constraints
The matlab.unittest.constraints.IsEqualTo class has improved performance when
comparing equal values.

Compatibility Considerations
Before R2018b, the IsEqualTo constraint called isequal or isequaln to determine if the actual
and expected objects were equal. With release R2018b, the constraint can, sometimes, determine

11-30
Advanced Software Development

that the actual and expected objects are equal without calling these functions. In these cases, if the
objects being compared overload the isequal or isequaln functions, then whatever specialized
behavior these methods define is not used in the comparison.

App Testing Framework: Programmatically choose tree node


The choose method now supports programmatic selection of tree nodes in your app tests. For more
information, see matlab.uitest.TestCase.choose.

Performance Testing Framework: Measure execution time of fast code


more accurately with the TestCase.keepMeasuring method
Performance tests that execute too quickly for MATLAB to time accurately are filtered with an
assumption failure. With the keepMeasuring method, the testing framework can measure
significantly faster code by automatically determining the number of times to iterate through code
and measuring the average performance. Use the keepMeasuring method within the condition of a
while loop. For more information, see matlab.perftest.TestCase.keepMeasuring and
Measure Fast Executing Test Code.

Mocking Framework: Invoke function upon mocked method call


You can specify that, each time you call a mocked method, it calls another function. For example,
specify that each time you call a mocked roll method, it calls the randi function.

To specify that a mock method uses a function handle to invoke another function, define behavior
with the Invoke class of the matlab.mock.actions package. This action differs from the
AssignOutputs action, which returns values that are defined when you create the AssignOutputs
instance.

For more information, see matlab.mock.actions.Invoke.

Mocking Framework: Verify interactions on mock occurred in order


You can create a constraint that is satisfied if interactions with a mock occurred in a specific order.
Use the 'RespectingOrder' option with matlab.mock.constraints.Occurred to verify that
mock methods were called and properties were accessed and set in a particular order.

For more information, see matlab.mock.constraints.Occurred.

Mocking Framework: Clear history of recorded mock object


interactions
Use the clearMockHistory method of matlab.mock.TestCase to clear the history of recorded
mock object interactions. For more information, see matlab.mock.TestCase.clearMockHistory.

matlab.test.behavior.Missing class: Verify class satisfies missing-value


behavior contract
Create a test class that derives from the matlab.test.behavior.Missing class to test if the
missing value for the class satisfies the missing-value contract in MATLAB. If your class represents a

11-31
R2018b

data type and you want MATLAB to treat missing values of your class similar to built-in classes,
ensure that your class satisfies the missing-value contract.

Typically, you use the behavior test as part of a test-driven development workflow. If you want the
missing value for your class to satisfy the missing contract with MATLAB, write the behavior test and
modify the class under test until the test results are as you expect.

For more information, see matlab.test.behavior.Missing.

MEX Functions: Build Fortran MEX Files with Interleaved Complex API
The Fortran Matrix API supports the interleaved storage representation of complex numbers. For
more information, see MATLAB Support for Interleaved Complex API in MEX Functions.

Note To run a Fortran MEX file built with the interleaved complex API in R2018a, you must use
R2018a Update 3.

Compatibility Considerations
If you build Fortran MEX functions, then you should review the Do I Need to Upgrade My MEX Files
to Use Interleaved Complex API? topic.

The functionality for several Fortran Matrix API functions has changed. For information, see:

• “Fortran Matrix API functions mxGetPi, mxSetPi, mxGetImagData, and mxSetImagData


incompatible with interleaved complex API” on page 11-34
• “Change of behavior for Fortran Matrix API functions mxGetPr, mxSetPr, mxGetData, and
mxSetData” on page 11-34
• “Change of behavior for Fortran Matrix API function mxGetElementSize” on page 11-34
• “Change of behavior for Fortran Matrix API functions mxCopyComplex16ToPtr,
mxCopyPtrToComplex16, mxCopyComplex8ToPtr, and mxCopyPtrToComplex8” on page 11-34

Compiler support changed for building MEX files and standalone


MATLAB engine and MAT-file applications
Support Compiler Platform
Added MinGW-w64 version 6.3.0 compiler from https://mingw- Windows
w64.org
Added Intel Parallel Studio XE 2018 with Microsoft Visual Studio Windows
2015 and 2017 for C, C++, and Fortran
Added Intel Parallel Studio XE 2018 for Fortran macOS
®
Discontinued Microsoft Visual C++ 2013 Professional Windows

To ensure continued support for building your MEX files, consider upgrading to another supported
compiler. For an up-to-date list of supported compilers, see Supported and Compatible Compilers.

11-32
Advanced Software Development

System objects: Flexible requirements for inputs when calling System


objects
In MATLAB, you can now call System objects with fewer inputs than those defined in the stepImpl
or outputImpl methods. When the System object runs, the algorithm determines how inputs are
used. This flexibility matches default MATLAB behavior for other functions and objects.

The System object algorithm might not be flexible for inputs depending on how the algorithm is
implemented or if the System object implements the getNumInputsImpl method.

System object authoring: Use enumerations to define finite property


lists in System objects
When adding a System object property with a finite list of values, use enumerations to define the
allowed values. To add enumerations, open your System object file in the MATLAB editor, and select
Insert Property > Enumerations.

For information about converting StringSets to enumerations, see “System object authoring StringSet
class will be removed” on page 11-35.

Reference Architecture: Deploy and run MATLAB on Amazon Web


Services (AWS) and Microsoft Azure
You can deploy and run the MATLAB desktop on AWS and Azure® and connect to it using the Remote
Desktop Protocol (RDP). Use a MathWorks provided AWS CloudFormation template to deploy to AWS
and an Azure Resource Manager (ARM) template to deploy to Microsoft Azure. For more information,
see MATLAB in the Cloud (https://www.mathworks.com/cloud.html). For reference architecture
deployment details, see:

• MATLAB on AWS
• MATLAB on Azure

Git Stashes: Store uncommitted changes for later use


Starting in R2018b, you can use Git stashes directly from MATLAB. You can create a Git stash to
store uncommitted changes for later use. For details, see Use Git Stashes.

Functionality being removed or changed


matlab.unittest.plugins.FailureDiagnosticsPlugin is not recommended
Still runs

The matlab.unittest.plugins.FailureDiagnosticsPlugin class is not recommended. Use


the matlab.unittest.plugins.DiagnosticsOutputPlugin class instead. There are no plans to
remove FailureDiagnosticsPlugin at this time.

Programmatic dependence on specific diagnostic subclass from getDiagnosticFor method


of constraint and tolerances

11-33
R2018b

Rework code that relies on properties or methods specific to


matlab.unittest.diagnostic.ConstraintDiagnostic instances returned from the
getDiagnosticFor method of matlab.unittest.constraints classes.

As of R2018b, diagnostics returned from constraint and tolerance classes in the


matlab.unittest.constraints package are instances of
matlab.unittest.diagnostics.FrameworkDiagnostic.

Protected access for matlab.unittest.fixtures.Fixture.onFailure


Behavior change in future release

The matlab.unittest.fixtures.Fixture.onFailure method will have protected access in a


future release. Currently, the Fixture.onFailure method has public access. However, this method
is designed to be used in subclasses of the Fixture class. In a future release, the
Fixture.onFailure method will have protected access, which restricts use of the method to
subclasses of the matlab.unittest.fixtures.Fixture class.

Fortran Matrix API functions mxGetPi, mxSetPi, mxGetImagData, and mxSetImagData


incompatible with interleaved complex API
Still runs

Do not use mxGetPi and mxSetPi functions in Fortran MEX files built with the interleaved complex
API (mex option -R2018a). Use mxGetComplexDoubles (Fortran) instead of mxGetPr and
mxGetPi.

Do not use mxGetImagData and mxSetImagData functions in Fortran MEX files built with the
interleaved complex API (mex option -R2018a). Use Typed Data Access functions instead.

For more information, see MATLAB Support for Interleaved Complex API in MEX Functions.

Change of behavior for Fortran Matrix API functions mxGetPr, mxSetPr, mxGetData, and
mxSetData
Still runs

Do not use the mxGetPr and mxSetPr functions in Fortran MEX files built with the interleaved
complex API (mex option -R2018a) for complex arrays. Use these functions for real arrays only, or
use Typed Data Access functions.

Do not use the mxGetData and mxSetData functions in Fortran MEX files built with the interleaved
complex API (mex option -R2018a) for numeric arrays. Use these functions for nonnumeric arrays
only. For numeric arrays, use Typed Data Access functions.

Change of behavior for Fortran Matrix API function mxGetElementSize


Behavior change in future release

For a complex Fortran mxArray built with the interleaved complex API (mex option -R2018a),
mxGetElementSize (Fortran) returns twice the value that the function in the separate complex
API returns.

Change of behavior for Fortran Matrix API functions mxCopyComplex16ToPtr,


mxCopyPtrToComplex16, mxCopyComplex8ToPtr, and mxCopyPtrToComplex8
Behavior change in future release

The function signatures for Fortran Matrix API functions mxCopyComplex16ToPtr (Fortran),
mxCopyPtrToComplex16 (Fortran), mxCopyComplex8ToPtr (Fortran), and

11-34
Advanced Software Development

mxCopyPtrToComplex8 (Fortran) are different for MEX files built with the interleaved complex
API (mex option -R2018a). The functions built with the separate complex API have two arguments for
the data, the real and complex parts. The functions built with the interleaved complex API have a
single argument for the data.

System object authoring StringSet class will be removed


Still runs

The class matlab.system.StringSet will be removed in a future release. To bring System object
infrastructure closer to MATLAB classes, regular MATLAB enumerations replace the System object-
specific StringSet functionality. To define a finite set of properties in System objects, use
enumerations instead.

Update Code

StringSet Properties Enumeration Properties


properties In your System object class, define the property:
Flavor = 'Chocolate'
end properties
Flavor (1,1) FlavorValues
properties (Hidden,Constant) end
FlavorSet = matlab.system.StringSet...
({'Vanilla','Chocolate'}) In a separate file, define the enumeration class:
end
classdef FlavorValues < int32
enumeration
Chocolate (0)
Vanilla (1)
end
end

In the MATLAB Editor, use the Insert Property > Enumeration for help in creating the
enumeration class.

Compatibility Considerations
MATLAB enumerations do not support special characters or spaces for the enumeration values. When
converting from StringSets to enumerations, remove or replace these characters in the enumeration
class.

matlab.editor.autoformat.DoubleHashtagForHeading setting has been removed


Errors

The matlab.editor.autoformat.DoubleHashtagForHeading setting has been removed. Use


the matlab.editor.autoformat.HashtagsForHeading setting instead.

To update your code, change instances of the setting


matlab.editor.autoformat.DoubleHashtagForHeading to
matlab.editor.autoformat.HashtagsForHeading. For more information, see matlab.editor
Settings.

11-35

You might also like