Matlab Release Notes
Matlab Release Notes
Matlab Release Notes
Phone: 508-647-7000
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
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
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
Graphics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-26
v
App Building . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-41
Performance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-47
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
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
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
R2023a
Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-2
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
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
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
Graphics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-21
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
Performance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-32
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
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
R2022b
Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-2
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
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
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
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
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
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
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
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
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
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
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
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
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
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
Mathematics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 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
Performance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-33
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
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
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
xxv
Functionality being removed or changed . . . . . . . . . . . . . . . . . . . . . . . . 6-13
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
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
R2020b
Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-2
xxviii Contents
Language and Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-5
xxix
Serial Port Interface: Improved performance . . . . . . . . . . . . . . . . . . . . . 7-14
Functionality being removed or changed . . . . . . . . . . . . . . . . . . . . . . . . 7-15
Mathematics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-17
Graphics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-18
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
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
R2020a
Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-2
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
Mathematics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-22
xxxiii
sparse Function: Support for integer subscripts and logical aggregation
..................................................... 8-22
Graphics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-23
Performance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-33
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
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
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
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
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
xxxvii
Mathematics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-26
Graphics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-27
Performance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 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
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
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
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
Graphics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-20
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
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
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
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
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
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
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
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.
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.
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”.
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")
For more information about creating sections, see “Create and Run Sections in Code”.
For more information, see “Find and Replace Text in Files and Go to Location”.
1-4
Environment
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”.
1-5
R2023b
For example, to open the Code Issues panel, click the Open more panels button ( ), and select the
Code Issues panel.
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
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.
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.
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
For example, create a dictionary that is configured to accept strings as keys and doubles as values.
d = configureDictionary("string","double")
d =
• 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.
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
1-10
Language and Programming
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 =
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:
This call to get could lead to infinite recursion if the property assignment in the get method is
unconditional.
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.
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 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.
• 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
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:
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.
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
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.
1-15
R2023b
For more information, see “Direct Calculations on Tables and Timetables” and “Rules for Table and
Timetable Mathematics”.
1-16
Data Analysis
• 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
• 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.
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
1-20
Data Import and Export
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.
Setting the compression level to zero disables the deflate filter. Previously, the deflate filter could be
enabled with a compression level of zero.
1-21
R2023b
[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
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.
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").
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
• 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".
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.
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.
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.
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.
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.
• More options for formatting slice labels, slice placement, and colors
• Data tips that appear when you move the cursor over the slices
You can also use the orderedcolors function to get the RGB triplets for any of the palettes.
1-26
Graphics
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
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(["Vanilla","Chocolate","Cherry","Almond"],[1 2 3 4])
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".
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
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.
1-32
Graphics
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)
1-33
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.
Previously, MATLAB did not generate code when changing the camera view using the Camera 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.
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
The spinmap function will be removed in a future release. There is no replacement for this function.
These functions and menu items will no longer support printing or exporting UI components in a
future release:
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]);
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:
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
These functions and menu items will no longer support creating full-page PostScript® (.ps) files in a
future release:
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.
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.
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.
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])
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
fig = uifigure;
sld = uislider(fig,"range",Value=[10 60]);
1-41
R2023b
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;
Apple: 0.5
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
1-43
R2023b
1-44
App Building
For more information about using HTML UI components, see “Create HTML Content in Apps”.
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.
fig = uifigure(Scrollable="on");
b = uibutton(fig,"state",Position=[fig.Position(3)+100 100 100 22]);
testCase = matlab.uitest.TestCase.forInteractiveUse;
testCase.press(b)
1-46
Performance
Performance
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
s = StorageClass(1:1e6);
timeit(@()s.movingAverage)
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.
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
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)
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
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
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.
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
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)
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
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)
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
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)
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.
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.
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
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)
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))
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.
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.
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];
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
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.
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
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”.
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.
R2023a: 17.1 s
R2023b: 13.6 s
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.
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.
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.
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)
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.
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
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
1-59
R2023b
To open the Source Control panel, use the Open more panels button ( ) in the sidebar.
1-60
Software Development Tools
• 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 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
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")
fig = uifigure(Scrollable="on");
b = uibutton(fig,"state",Position=[fig.Position(3)+100 100 100 22]);
testCase = matlab.uitest.TestCase.forInteractiveUse;
testCase.press(b)
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.
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
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”.
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.
• 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.
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”.
• 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”.
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.
1-65
R2023b
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.
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
1-67
2
R2023a
Version: 9.14
New Features
Bug Fixes
Compatibility Considerations
R2023a
Environment
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.
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.
2-2
Environment
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.
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
2-6
Environment
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
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.
issues =
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 =
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 =
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 =
{[4 5 6]}
Perform a lookup using curly braces. The lookup returns the value as an array.
d{2}
ans =
[4 5 6]
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
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.
For more information, see Direct Calculations on Tables and Timetables and Rules for Table and
Timetable Mathematics.
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
2-12
Data Analysis
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:
• 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.
Compatibility Considerations
The "all" computation method now returns the number of unique values in addition to the
computation methods in the previous release.
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
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")
For example, return the ISO day of week number for today.
D = datetime("today");
dayNumber = day(D,"iso-dayofweek")
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
2-16
Data Import and Export
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.
2-17
R2023a
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
• 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.
For example, you can create a 5-by-5 random logical array using randi([0 1],5,"logical").
2-19
R2023a
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
2-21
R2023a
tiledlayout("horizontal")
x = 1:5;
nexttile
plot(x)
nexttile
bar(x);
nexttile
contourf(peaks)
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.
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
2-24
Graphics
• 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
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 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.
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
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.
2-28
App Building
Previously, you had to first unassign the assigned callback from the component before creating a new
callback.
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)
The options set by the InteractionOptions object apply to these interactions on the associated
axes:
For example, limit all pan and zoom interactions to the x-dimension only.
fig = uifigure;
ax = uiaxes(fig);
ax.InteractionOptions.LimitsDimensions = "x";
2-29
R2023a
• 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.
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.
2-30
App Building
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
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.
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 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
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.
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
• 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);
tic
tt2 = tt(t,:);
toc
end
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);
tic
tt2 = tt(t,:);
toc
end
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);
tic
tt2 = tt(wt,:);
toc
end
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.
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;
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
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.
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
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)
• 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
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.
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
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)
For example, this code runs about 4x faster than in the previous release.
rng default
N = 1e5;
2-38
Performance
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.
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
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.
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
These operations were timed on a Windows 10, Intel Xeon CPU E5-1650 v4 @ 3.60 GHz test system.
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
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.
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)
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.
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.
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
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.
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
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
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:
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
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
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
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.
2-47
R2023a
comparison = visdiff(textfile1,textfile2);
file = publish(comparison);
web(file)
2-48
Software Development Tools
project path, project settings, shortcuts, labels, and referenced projects. For more information, see
Compare MATLAB Projects in MATLAB Online.
2-49
R2023a
For more information, see Collect Statement and Function Coverage Metrics for MATLAB Source
Code.
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.
2-50
Software Development Tools
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)
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);
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
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.
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.
clib.libname.funcname
clib.libname.funcname(5)
2-53
R2023a
e = jenv("jre_path")
You might have to restart your MATLAB session to change to this version.
2-54
External Language Interfaces
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.
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
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.
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.
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.
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
2-58
3
R2022b
Version: 9.13
New Features
Bug Fixes
Compatibility Considerations
R2022b
Environment
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.
• 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.
3-2
Environment
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
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.
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
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.
3-6
Environment
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
d =
"Unicycle" ⟼ 1
"Bicycle" ⟼ 2
"Tricyle" ⟼ 3
d("Bicycle")
ans =
In almost all use cases, dictionary performs faster than containers.Map. For more information,
see dictionary.
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])
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.
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.
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
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
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.
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.
• 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
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.
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.
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")
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.
Additionally, in these Live Editor tasks, you can specify to output a table with logical variables:
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.
3-14
Data Analysis
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.
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.
For all other data types except for structure arrays and objects:
Previously, you could interactively replace the current data selection with empty arrays for
nontabular data only.
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 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.
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)
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
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
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
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
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 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
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 = duration
15:53:28
d1 = datetime("2022-01-01")
d2 = datetime("now")
elapsedTime = between(d1,d2)
elapsedTime = calendarDuration
6mo 18d 13h 19m 18.5561949999974s
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
Test whether you can create subsets of these datastore objects using the isSubsettable function.
isSubsettable returns true when the underlying datastore can be subset.
Use these two new functions to convert to and from CDF_TIME_TT2000 int64 timestamps:
3-22
Data Import and Export
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
These qr, gsvd, and svd syntaxes for performing economy-size decompositions are no longer
recommended:
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.
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
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")
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.
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
These arguments can be any numeric values as well as datetime, duration, and categorical values:
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
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.
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"])
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.
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.
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.
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
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.
These functions and menu items will no longer support printing or exporting UI components in a
future release:
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.
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:
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");
These functions and menu items will no longer support creating full-page PostScript (.ps) files in a
future release:
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 in a future release. To configure printer defaults, use the
options provided by your operating system.
3-33
R2022b
App Building
• 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".
3-34
App Building
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
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.
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.
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.
3-37
R2022b
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:
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
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)
• 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
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
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)
• 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
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
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
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.
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
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)
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
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.
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
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.
• 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)
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
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 code was timed on a Windows 10, Intel Xeon CPU E5-2660 @ 2.20 GHz test system by calling the
myapp function:
myapp
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
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)
function t = timingTest
data = parquetread("airlinesmall.parquet");
arrds = arrayDatastore(data,OutputType="same");
tic;
t = readall(arrds);
toc;
end
3-48
Performance
The code was timed on a Windows 10, Intel Xeon (R) W-2133 @ 3.60 GHz test system by calling the
timingTest function.
index = 1;
c = cell([ceil(numpartitions(arrds)/100) 1]);
tic;
while hasdata(arrds)
c{index} = read(arrds);
index = index + 1;
end
toc;
end
The code was timed on a Windows 10, Intel Xeon (R) W-2133 @ 3.60 GHz test system by calling the
timingTest function.
tic;
for i = 1:20
t = parquetread("airlinesmall.parquet",SelectedVariableNames=varNames);
end
toc;
end
3-49
R2022b
The code was timed on a Windows 10, Intel Xeon (R) W-2133 @ 3.60 GHz test system by calling the
timingTest function.
tic;
for i = 1:20
pds = parquetDatastore(filenames);
end
toc;
end
The code was timed on a Windows 10, Intel Xeon (R) W-2133 @ 3.60 GHz test system by calling the
timingTest function.
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.
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
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
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
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
For example, create a test class with parameterization properties that are set using cell arrays.
Create a test suite from the class and return the names of the suite elements.
ans = ans =
{'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);
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)))
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
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.
3-55
R2022b
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.
pyargs(A=1,B=2)
ans =
A: 1
B: 2
3-56
External Language Interfaces
• double
• single
• int8
• uint8
• int16
• uint16
• int32
• uint32
• int64
• uint64
• logical
For information about conversion functions, see MATLAB to Python Data Type Mapping.
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')
For information about using the MATLAB Engine API for Python, see Call MATLAB from Python.
3-57
R2022b
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.
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.
3-59
4
R2022a
Version: 9.12
New Features
Bug Fixes
Compatibility Considerations
R2022a
Environment
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.
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.
For more information about inserting hyperlinks, see Format Text in the Live Editor.
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.
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
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.
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.
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.
4-5
R2022a
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.
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
• 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.
4-7
R2022a
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.
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.
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.
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.
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
Thrown error reports will no longer include the line number of where the error occurred.
4-9
R2022a
Data Analysis
• 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.
Previously, the quantile, prctile, and iqr functions required Statistics and Machine Learning
Toolbox.
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.
• 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
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.
• 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.
4-12
Data Analysis
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
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 =
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
These functions provide support for using patterns when you specify category names:
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.
T = readtable("outages.csv","TextType","string")
T =
1468×6 table
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
________________ ________________
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
• smoothdata
• normalize
• filloutliers
• fillmissing
• standardizeMissing
• ischange
• islocalmax
• islocalmin
• ismissing
4-15
R2022a
• isoutlier
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.
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.
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).
• 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).
4-17
R2022a
• 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.
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
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
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.
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 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.
For more information about updating your code to use the recommended functionality, see Transition
Your Code to serialport Interface.
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 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.
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.
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.
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.
• 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).
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 an LDL factorization for full matrices that are Hermitian indefinite. Instead,
the LU factorization is used for these matrices.
4-22
Graphics
Graphics
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")
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.
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.
Before R2022a, linkaxes supported only 2-D Cartesian axes and synchronized the x-axis and y-axis
limits by default.
4-27
R2022a
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.
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
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.
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 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.
im2java will be removed in a future release. There is no replacement for this function.
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
• 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.
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 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 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.
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)
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.
4-32
App Building
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.
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.
• 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.
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.
For more information, see Use Grid Layout Managers in App Designer.
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
open the Comparison Tool, click Compare in the Designer tab of the App Designer Toolstrip.
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
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.
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
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
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
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.
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;
R2021b:
4-39
R2022a
R2022a:
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.
classdef MyClass
methods (Static)
function out = staticMethod(in)
out = in;
end
end
end
classdef PackageClass
properties (Constant)
constantProperty = 3;
end
end
function testTryPerformance
x = 1;
for i = 1:1e8
try
x = x * i;
catch
warning("Assignment was not successful.")
x = 1;
end
end
end
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)
• 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
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
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.
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:
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()
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))
R2021b: 42 s
R2022a: 3.6 s
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.
• 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
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
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
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.
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
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
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
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.
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
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.
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
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.
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
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
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.
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
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.
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
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
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
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.
The speed increase improves as the number of UIAxes components that lie off the canvas increases.
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.
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.
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");
% 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
4-50
Performance
end
end
end
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
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
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
4-53
R2022a
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.
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
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"
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")
• 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.
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
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);
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
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.
• 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.
You can specify the SHAPE of the argument as ["len","typeSz"]. For more information, see
Define Missing SHAPE Parameter.
• std::vector as data member.
• 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
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 does not support Name,Value syntax for passing keyword arguments.
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'}))
Related documentation
For the related documentation, see Error Converting Elements of list or tuple.
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.
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.
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.
with:
4-60
External Language Interfaces
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
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).
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.
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
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.
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.
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
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
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
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.
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.
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.
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
5-9
R2021b
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.
• Run other MATLAB code at the same time as a long running calculation
• Create more responsive user interfaces
5-10
Language and Programming
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 =
When the Command Window is not wide enough to display the full array, the size, the class, and an
annotation are shown:
myStruc =
Starting in R2021b, you can inherit from three new superclasses to customize parentheses, dot, and
brace indexing operations individually:
5-11
R2021b
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.
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.
5-12
Language and Programming
5-13
R2021b
Data Analysis
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.
• 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.
5-14
Data Analysis
• fillmissing
• filloutliers
• ischange
• islocalmax
• islocalmin
• isoutlier
• rmoutliers
• smoothdata
• 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.
5-15
R2021b
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.
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.
5-16
Data Import and Export
• 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.
• 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
For more information on data type mapping between the NetCDF API and MATLAB, see Map NetCDF
API Syntax to MATLAB Syntax.
• audioread
• audiowrite
• imwrite
• VideoReader
• VideoWriter
• 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.
5-18
Data Import and Export
For more information about these apps, see Serial Explorer and TCP/IP Explorer.
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.
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
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.
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.
5-22
Graphics
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.
plot([0 3 1 6 4 10])
exportgraphics(gca,'mycharts.pdf')
bar([10 20 30 40])
exportgraphics(gca,'mycharts.pdf','Append',true)
5-24
Graphics
p = patch;
p.UserData = p.XData;
p.DataTipTemplate.DataTipRows(3) = dataTipTextRow('XDataAsUserData','UserData');
For more details on interacting with MATLAB figures, see Control Chart Interactivity.
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.
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')
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'.
• 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.
5-26
App Building
For more information, see Use the Background to Make Your Apps More Responsive.
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.
5-27
R2021b
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
(,)
5-28
App Building
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.
5-29
R2021b
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.
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).
5-30
App Building
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.
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.
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.
5-31
R2021b
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.
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
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
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.
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 code was timed on a Windows 10, Intel Xeon W-2133 CPU @ 3.60 GHz test system by calling the
timingQRMod function.
• 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
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.
5-34
Performance
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(:),".")
5-35
R2021b
plot(ax,y);
toc;
end
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.
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:
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
These operations were timed on a Windows 10, Intel Core i7-5600 CPU @ 2.60 GHz test system.
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.
5-36
Performance
R2021a: 20 s
R2021b: 1.5 s
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.
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.
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.
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
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.
• 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);
5-38
Performance
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.
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.
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
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.
5-40
Software Development Tools
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.
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.
5-41
R2021b
f = uifigure;
ax = axes(f);
plot(ax,1:10)
tc = matlab.uitest.TestCase.forInteractiveUse;
tc.press(ax,[3 2],'SelectionType','open')
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.
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
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
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.
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.
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.
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.
• 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
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.
For information about developing these Java programs, see Call Back into MATLAB from Java.
5-45
R2021b
def returnData(data):
return data
mc = complex(magic(3));
c = py.test.returnData(mc)
c =
Python memoryview:
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.
Compatibility Considerations
Download the latest version 3.4.2 release of the Apache CXF tool from https://cxf.apache.org/
download.
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.
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=', ')
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)
with:
matlab.wsdl.createWSDLClient(url)
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.
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
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.
• 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.
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.
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
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.
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'
For more information, see “Start and Stop MATLAB Drive Connector”
6-5
R2021a
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
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
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.
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.
6-8
Language and Programming
Compatibility Considerations
With the additional context, MATLAB resolves ambiguities differently than in previous releases. Some
code now produces errors or warnings.
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
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
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'
6-10
Language and Programming
limitwidth =
logical
0
6-11
R2021a
Data Analysis
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.
[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.
• 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.
• 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.
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'}
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
• 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:
• 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.
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.
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
Additionally, on Windows systems, unzip and untar replace invalid characters with underscores if
they occur in entry path names of the original file.
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
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.
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 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.
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.
Previously, this functionality was available in interp1 for 1-D interpolation, but this improvement to
griddedInterpolant adds support for N-D multivalued interpolation.
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
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.
• '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
• '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.
• '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.
6-24
Graphics
• 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.
• 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.
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
6-26
Graphics
Padding Changes
Previous Padding Option R2021a Padding Option How to Update Your Code
'normal' 'loose' Consider changing instances of
'normal' to 'loose'.
6-27
R2021a
Previous Padding Option R2021a Padding Option How to Update Your Code
'compact' 'compact' No changes needed.
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:
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:
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:
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
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.
The 'alwaysontop' property value is available only in figures created using the uifigure function.
6-32
App Building
To configure a custom UI component class for use in App Designer, follow these steps:
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.
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.
6-34
App Building
fig = uifigure;
uialert(fig,'File not found','Invalid File')
tc = matlab.uitest.TestCase.forInteractiveUse;
tc.dismissAlertDialog(fig)
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.
To create new apps, use App Designer and the appdesigner function instead. App Designer is the
recommended app development environment in MATLAB.
For more information about App Designer, go to Comparing GUIDE and App Designer on
mathworks.com.
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:
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:
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:
6-36
Performance
Performance
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
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.
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
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.
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
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)
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
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.
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
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
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.
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
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)
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
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.
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.
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
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
• 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
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.
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
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);
Thread-based parallel pools support only a subset of MATLAB and testing framework functionality.
For more information, see runInParallel or runtests.
6-45
R2021a
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.
fig = uifigure;
uialert(fig,'File not found','Invalid File')
tc = matlab.uitest.TestCase.forInteractiveUse;
tc.dismissAlertDialog(fig)
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
<, >, ', ", and &, 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.
patchdemoxmlfile D:\Work\mytoolbox\help
6-46
External Language Interfaces
• 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.
• 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.
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.
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.
• 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
• HTS221
• LPS22HB
• LSM303C
• LSM6DSL
• LSM9DS1
• MPU-6050
• MPU-9250
6-49
7
R2020b
Version: 9.9
New Features
Bug Fixes
Compatibility Considerations
R2020b
Environment
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.
• canUseGPU
• canUseParallelPool
Use these functions to check supported functionality and avoid executing code that relies on specific
hardware constraints.
visdiff('filename1.m','filename2.m');
7-3
R2020b
7-4
Language and Programming
str = "String arrays were introduced in R2016b. Patterns were added in R2020b.";
extract(str,pat)
ans =
2x1 string array
"R2016b"
"R2020b"
7-5
R2020b
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'.
• 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.
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
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 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.
-
.* 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.
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.
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
• 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:
7-10
Data Import and Export
• Use the readstruct function to read structured data stored as XML files.
• Use the writestruct function to write MATLAB structures to XML files.
• '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.
7-11
R2020b
The transform function creates one TransformedDatastore object from the resulting
transformation. For more information on the TransformedDatastore object, see
TransformedDatastore.
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.
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
_____________ ______________ _______ __________________
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);
7-13
R2020b
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:
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);
% 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
s.BaudRate
7-14
Data Import and Export
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))
• '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 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.
7-16
Mathematics
Mathematics
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
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.
• 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
• 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.
• 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
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';
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
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.
7-23
R2020b
7-24
Graphics
7-25
R2020b
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')
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 =
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
7-29
R2020b
App Building
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.
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.
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.
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.
• 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.
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.
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.
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.
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.
Additionally, you can now migrate GUIDE apps that use ginput or gtext. For more information, see
GUIDE Migration Strategies.
• 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
tc = matlab.uitest.TestCase.forInteractiveUse;
tc.chooseContextMenu(fig,m1)
tc = matlab.uitest.TestCase.forInteractiveUse;
tc.drag(ax,[3 2],[4 2])
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 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.
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.
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 =
Button (Button)
UIAxes
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.
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
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
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.
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
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.
• 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
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
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)
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
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
function timingTest
lb = uilistbox;
lb.Items = "Item " + (1:1000);
lb.ItemsData = 1:1000;
lb.Multiselect = true;
lb.Value = 1:800;
end
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)
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
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
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
• 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.
7-43
R2020b
%#function parallel.Pool
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.
tc = matlab.uitest.TestCase.forInteractiveUse;
tc.chooseContextMenu(fig,m1)
tc = matlab.uitest.TestCase.forInteractiveUse;
tc.drag(ax,[3 2],[4 2])
7-44
Software Development Tools
Starting in R2020a Update 5, SVN cleanup only removes stale locks and unfinished transactions. It
does not remove unversioned or 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.
The ProfileReport class has been removed. Use CoverageReport or CoberturaFormat instead.
Compared to ProfileReport, these two classes generate more accurate code coverage reports.
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
To create a MATLAB Profiler Coverage Report without specifying a ProfileReport format, see
Determine Code Coverage Using the Profiler.
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
This table shows the outcome of the choose gesture on a toggle button that is specified with index 2.
If this behavior change impacts your code, update the index or replace it with the appropriate button
label.
7-46
External Language Interfaces
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.
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.
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
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).
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.
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
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 t = 1:1000000
if ~mod(t, 10000)
disp(t)
end
end
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
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
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 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.
For more information about setting your documentation location, see Help Preferences.
8-4
Environment
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
For more information on setting up MATLAB to access your online storage service, see Work with
Remote Data.
bin2dec('111')
bin2dec('0b111')
bin2dec('0b111s32')
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
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'
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.
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
• 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
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.
The class matlab.system.StringSet will be removed in a future release to bring System object™
authoring closer to MATLAB classes.
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.
• 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.
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.
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 =
Starting in R2020a, the empty method does not accept inputs that are not numeric or logical.
a = double.empty(0,'b')
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
In R2020a, MATLAB offers four tasks for manipulating data in tables and timetables:
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.
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
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.
T = leapseconds
[T,vers] = leapseconds
8-13
R2020a
[T,vers] = timezones
For more information on the IANA Time Zone Database, see IANA Time Zone Database.
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.
• 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.
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
• 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).
8-15
R2020a
Function Changes
groupsummary and grouptransform groupsummary and grouptransform can now
operate on multidimensional variables in a tall
table or tall timetable.
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.
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
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.
• 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.
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.
• writetable
• writetimetable
• writematrix
• writecell
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.
8-18
Data Import and Export
• 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.
8-19
R2020a
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.
on = matlab.lang.OnOffSwitchState.on;
jsonencode(on)
ans =
'"on"'
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
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.
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. To programmatically import HDF4 or HDF-EOS files, use the hdfread
function instead.
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
• 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.
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
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:
8-24
Graphics
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.
Y = [50 20 15 15];
pareto(Y,1)
8-25
R2020a
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'.
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
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
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.
8-27
R2020a
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.
For example, the following code sets the axes ActivePositionProperty to 'position'.
ax = gca;
ax.ActivePositionProperty = 'position';
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.
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.
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
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.
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
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.
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.
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'.
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™.
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.
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.
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.
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;
uit = uitable(fig,'Data',tdata);
uit.RowName = 'numbered';
8-32
Performance
Performance
for t = 1:1000000
if ~mod(t, 10000)
disp(t)
end
end
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.
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
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
• 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
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
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
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.
• 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
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
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.
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
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
For example, a JPEG image with a resolution of 5120x3840 is read about 2.1x faster in R2020a:
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.
For example, a matrix that is 30,000 x 30,000 elements in size is read about 1.1x faster in R2020a:
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
function timingOde15s
[t,y] = ode15s(@vdp1000,[0 1e5],[2; 0]);
end
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
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
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
function timingTest
rng default
A = rand(1e4);
tic
At = A';
toc
end
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.
function timingOrdschur
rng default
A = randn(2000);
[U,S] = schur(A,'real');
tic
[U,S] = ordschur(U,S,'lhp');
toc
end
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
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.
tic
A = sparse(i,j,v,m,n);
toc
end
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.
for k = 1:10000
8-40
Performance
vq = interp1(x,v,xq);
end
end
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)
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.
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
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)
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.
8-42
Performance
Similarly, in apps with approximately 4500 lines of code, adding and deleting a function are about
1.8x faster and 2.8x faster, respectively.
These actions were timed on a Windows 10, Intel Xeon® CPU E5-1650 v3 @ 3.5GHz test system with
NVIDIA Quadro K620 graphics card.
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
end
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
end
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
end
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.
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));
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
end
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.
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.
8-46
Software Development Tools
• 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
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: 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:
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.
8-49
R2020a
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);
mock =
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 =
PropA: 5
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
To create a MATLAB Profiler Coverage Report without specifying a ProfileReport format, see
Determine Code Coverage Using the Profiler.
8-50
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 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.
• 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.
• wchar_t
• char16_t
• char32_t
• 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
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.
8-52
External Language Interfaces
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.
with:
matlab.wsdl.createWSDLClient(url)
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.
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')
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™.
Use the device instead of i2cdev and spidev to connect to I2C or SPI devices on Arduino
hardware .
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 .
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
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
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: 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
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';
9-5
R2019b
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.
addons =
1×4 table
9-6
Environment
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)
For more information, see Create Custom Settings. To create settings for custom toolboxes, see
Create Factory Settings for Toolboxes.
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 about file and folder uploading and downloading, see “Add Files to MATLAB Drive”.
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
You can call this function and immediately access the structure field it creates:
createStruct(3).aField
9-8
Language and Programming
For more information on setting up MATLAB to access your online storage service, see Work with
Remote Data.
• 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.
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.
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.
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.
9-10
Language and Programming
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.
enum = matlab.lang.OnOffSwitchState.off;
TF = strcmp({enum},'off')
TF =
logical
You can also compare {enum} to a cell array of character vectors or to a string array.
TF = strcmp({enum},{'on','off'})
TF =
0 1
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.
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
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
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
9-12
Language and Programming
function customValFcn(A)
fh = @sin;
% function body
end
9-13
R2019b
Data Analysis
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.
T =
5×2 table
Var1 Var2
____ ____
"A" 1
"B" 2
"C" 3
"A" 4
"A" 5
G =
3×2 table
Var1 Var2
____ ____
9-14
Data Analysis
"A" 1
"A" 4
"A" 5
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
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.
• 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.
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.
isregular vartype
outerjoin xcorr
setdiff xcov
setxor
9-16
Data Analysis
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
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:
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.
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
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
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.
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.
By default, saving a variable myVariable compresses the data and saves it to a version 7 MAT-file.
The -v7 flag is optional.
9-20
Data Import and Export
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?
• 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
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 =
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");
Compatibility Considerations
For more information about updating your code to use the recommended functionality, see Transition
Your Code to serialport Interface.
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.
The default setting for UseExcel on Windows systems with Excel installed is false.
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)
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:
This table shows a typical use of xlsfinfo and how to update your code to use sheetnames.
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.
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');
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.
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.
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 is not recommended. Use serialportlist instead. See Transition Your Code to
serialport Interface for more information about using the recommended functionality.
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.
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
• 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
• 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.
• 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
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.
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
For more about customizing axes interactions, see Control Chart Interactivity.
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'.
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
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')
• 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.
9-30
Graphics
'streets-light' 'satellite'
'streets-dark' 'topographic'
Hosted by Esri.
'streets'
General-purpose road
map that emphasizes
accurate, legible styling
of roads and transit
networks.
Hosted by Esri.
9-31
R2019b
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.
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.
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.
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.
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))
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.
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
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
Cell styles in table UI components are supported only in App Designer apps and in figures created
with the uifigure function.
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.
Sortable columns in table UI components are supported only in App Designer apps and in figures
created with the uifigure function.
9-36
App Building
HTML UI components are supported only in App Designer apps and in figures created with the
uifigure function.
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.
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.
For example,
9-37
R2019b
To open App Designer from the MATLAB toolstrip, click the Design App button in the Apps tab.
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.
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 Designer is the recommended app development environment in MATLAB. To create new apps,
use App Designer and the appdesigner function instead.
For more information about App Designer, go to Comparing GUIDE and App Designer on
mathworks.com.
9-38
App Building
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.
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:
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;
uit = uitable(fig,'Data',tdata);
uit.RowName = 'numbered';
9-40
Performance
Performance
• 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
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
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
• 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
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
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
• 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
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
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
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);
• 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
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
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
Verification passed.
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
9-46
Software Development Tools
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
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.
9-48
External Language Interfaces
Compatibility Considerations
To ensure continued support for your applications, upgrade to a supported version of Python, version
3.6 or 3.7.
• 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
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.
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:
In R2019a, the interface ignores the const type qualifier, allowing the MATLAB user to utilize const
objects incorrectly.
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.
9-50
External Language Interfaces
double val;
};
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. 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:
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
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
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
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.
10-4
Environment
After a folder is shared, you can manage the permissions of invited members, rescind invitations, or
send additional invitations at any time.
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.
For example, to run unit tests you created for your programs, from the operating system command
prompt, type:
10-5
R2019a
MATLAB:
For more information, see matlab (Windows), matlab (macOS), or matlab (Linux).
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.
10-6
Language and Programming
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.
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.
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.
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
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.
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.
• 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.
10-10
Data Analysis
You can also return the linear indices corresponding to the minimum and maximum values of the
input array using the 'linear' option.
addvars movevars
cospi normalize
groupcounts removevars
grouptransform sinpi
inner2outer splitvars
intersect svd
mergevars union
10-11
R2019a
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
• Use the readtimetable function to read timetables from text or spreadsheet files.
• Use the writetimetable function to write timetables to text or spreadsheet files.
For more information, see the setvaropts and detectImportOptions reference pages.
10-13
R2019a
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.
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
• 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.
For more information on the custom datastore framework, see Develop Custom Datastore.
10-15
R2019a
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).
In a future release, hdftool will be removed. To import HDF4 or HDF-EOS files, use the hdfread
function instead.
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.
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.
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.
This table shows typical usages of xlsread and xlswrite and how to update your code to use the
recommended read and write functions.
M = readmatrix(filename)
10-17
R2019a
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.
writetable(T,filename)
Write a matrix:
writematrix(M,filename)
writecell(C,filename)
For more information, see readmatrix, writematrix, readcell, writecell, readtable, and
writetable.
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
• 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.
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.
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);
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.
• 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.
10-21
R2019a
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.
Changing the FontSize property of a chart disables the automatic resizing of the fonts.
10-22
Graphics
See the documentation for a specific function or object to determine whether it accepts categorical
values.
Compatibility Considerations
Use the rendererinfo function instead of the opengl function to get information about the
graphics renderer.
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
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
Image components are supported only in App Designer apps and in figures created with the
uifigure function.
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: Create new apps using App Designer Start Page
options
From the App Designer Start Page you can now do the following.
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.
• 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.
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:
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).
10-27
R2019a
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
For example, on a test system, this code runs faster in R2019a than in previous releases.
A = repmat(eye(200),500,1);
sortrows(A)
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
10-30
Software Development Tools
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.
• matlab.unittest.TestCase.log
• matlab.unittest.TestRunner.withTextOutput
• matlab.unittest.plugins.TestRunProgressPlugin
• matlab.unittest.plugins.LoggingPlugin.withVerbosity
• matlab.unittest.plugins.DiagnosticsOutputPlugin
10-32
Software Development Tools
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.
In release R2019a, the IsEqualTo constraint always compares the size and type of column variables.
10-33
R2019a
If you have a C shared library, then use the loadlibrary function as described in C Libraries.
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.
10-34
External Language Interfaces
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
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.
Use device instead of i2cdev and spidev to connect to I2C or SPI devices on Arduino hardware.
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.
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
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.
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.
11-2
Desktop
press Ctrl+Shift+A. If the text contains both uppercase and lowercase text, MATLAB changes the
case to all uppercase.
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.
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.
11-3
R2018b
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.
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.
11-4
Desktop
You cannot edit a SHARED file in a Can View folder - this is indicated by a padlock icon .
11-5
R2018b
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.
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.
In the validateattributes function, the 'finite' and 'nonnan' attributes no longer require
that the input passes an isnumeric check.
11-6
Language and Programming
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.
11-7
R2018b
Mathematics
polyshape subtract
addboundary union
intersect xor
simplify
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.
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.
11-10
Graphics
11-11
R2018b
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'.
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.
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
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.
11-14
Data Import and Export
• 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.
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
• 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.
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.
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.
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.
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
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
11-17
R2018b
Data Analysis
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]).
11-18
Data Analysis
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.
11-19
R2018b
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.
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"]);
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
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
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: Control App Designer Code View settings using MATLAB
preferences
Control the following settings for App Designer Code View by setting MATLAB preferences:
When you set any of these preferences, the change applies to the MATLAB Editor and App Designer.
11-22
App Building
Grid layout managers are only available in apps created with the uifigure function.
Scrolling works only in App Designer apps, in figures created with the uifigure function, or in child
containers within those figures.
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.
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).
For information about other new features of deployed web apps, see Release Notes (MATLAB
Compiler).
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
Live Editor: Create new and open existing live scripts faster
New and existing live scripts open faster than in previous releases.
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).
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
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.
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.
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)
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:
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.
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.
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.
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:
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
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.
For information about converting StringSets to enumerations, see “System object authoring StringSet
class will be removed” on page 11-35.
• MATLAB on AWS
• MATLAB on Azure
11-33
R2018b
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.
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.
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.
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
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.
11-35