Language Fundamentals
Language Fundamentals
Entering Commands
ans Most recent answer
Create Grids
linspace Generate linearly spaced vector
Indexing
colon Vector creation, array subscripting, and for-loop iteration
Data Types
Numeric Types
Create Numeric Variables
double Double-precision arrays
Character Arrays
char Character array
convertStringsToChars Convert string arrays to character arrays, leaving other arrays unaltered
Match Patterns
Building Patterns
pattern Patterns to search and match text
Character-Matching Patterns
alphanumericsPattern Match letter and digit characters
Boundary Patterns
alphanumericBoundary Match boundary between alphanumeric and non-alphanumeric characters
Regular Expressions
regexp Match regular expression (case sensitive)
Edit
erase Delete substrings within strings
Compare
matches Determine if pattern matches strings
NaT Not-a-Time
Convert to Strings
char Character array
Categorical Arrays
Create Categorical Arrays
categorical Array that contains values assigned to categories
Summary Information
summary Print summary of table, timetable, or categorical array
Tables
Create Tables and Convert Type
table Table array with named variables that can contain different types
Rearrange Variables
addvars Add variables to table or timetable
Reshape
rows2vars Reorient table or timetable so that rows become variables
Customize Properties
addprop Add custom properties to table or timetable
Missing Values
ismissing Find missing values
Timetables
Create Timetables and Convert Type
timetable Timetable array with time-stamped rows and variables of different types
retime Resample or aggregate data in timetable, and resolve duplicate or irregular times
synchronize Synchronize timetables to common time vector, and resample or aggregate data from input timetables
withinrange Determine if timetable row times are within specified time range
Missing Values
ismissing Find missing values
Stacked Plot
stackedplot Stacked plot of several variables with common x-axis
Structures
struct Structure array
fieldnames Field names of structure, or public fields of Java or Microsoft COM object
Cell Arrays
cell Cell array
cell2mat Convert cell array to ordinary array of the underlying data type
Function Handles
function_handle Handle to function
Map Containers
containers.Map Object that maps values to unique keys
Time Series
Time Series Objects
Create, Modify, and Plot
timeseries Create timeseries object
synchronize Synchronize and resample two timeseries objects using common time vector
Query
get Query timeseries properties
Descriptive Statistics
iqr Interquartile range of timeseries data
Query
get Query tscollection properties
Other Types
is* Detect state
Subtraction
- Subtraction
diff Differences and approximate derivatives
Multiplication
.* Multiplication
* Matrix multiplication
Division
./ Right array division
Powers
.^ Element-wise power
^ Matrix power
Transpose
.' Transpose vector or matrix
Array Sign
uminus Unary minus
~= Determine inequality
Logical Operations
Short-circuit &&, || Logical operations with short-circuiting
| Find logical OR
Set Operations
intersect Set intersection of two arrays
Bit-Wise Operations
bitand Bit-wise AND
bitor Bit-wise OR
Subtraction
- Subtraction
Multiplication
.* Multiplication
* Matrix multiplication
Division
./ Right array division
Powers
.^ Element-wise power
^ Matrix power
Transpose
.' Transpose vector or matrix
Array Sign
uminus Unary minus
Trigonometry
Sine
sin Sine of argument in radians
Cosine
cos Cosine of argument in radians
Tangent
tan Tangent of argument in radians
Cosecant
csc Cosecant of input angle in radians
Secant
sec Secant of angle in radians
Cotangent
cot Cotangent of angle in radians
Hypotenuse
hypot Square root of sum of squares (hypotenuse)
Conversions
deg2rad Convert angle from degrees to radians
Complex Numbers
abs Absolute value and complex magnitude
i Imaginary unit
j Imaginary unit
Discrete Math
factor Prime factors
Polynomials
poly Polynomial with specified roots or characteristic polynomial
Special Functions
Bessel Functions
airy Airy Functions
Beta Functions
beta Beta function
Error Functions
erf Error function
Gamma Functions
gamma Gamma function
i Imaginary unit
j Imaginary unit
Inf Create array of all Inf values
Linear Algebra
Linear Equations
mldivide Solve systems of linear equations Ax = B for x
Matrix Decomposition
lu LU matrix factorization
qr QR decomposition
Matrix Operations
transpose Transpose vector or matrix
ctranspose Complex conjugate transpose
Matrix Structure
bandwidth Lower and upper matrix bandwidth
Matrix Properties
norm Vector and matrix norms
Interpolation
1-D and Gridded Interpolation
interp1 1-D data interpolation (table lookup)
interpn Interpolation for 1-D, 2-D, 3-D, and N-D gridded data in ndgrid format
Grid Creation
ndgrid Rectangular grid in N-D space
Optimization
fminbnd Find minimum of single-variable function on fixed interval
Stiff Solvers
ode15s Solve stiff differential equations and DAEs — variable order method
ode23tb Solve stiff differential equations — trapezoidal rule + backward differentiation formula
Get/Set Options
odeget Extract ODE option values
odeset Create or modify options structure for ODE and PDE solvers
odeset Create or modify options structure for ODE and PDE solvers
Convolution
conv Convolution and polynomial multiplication
Digital Filtering
filter 1-D digital filter
Sparse Matrices
Creation
spalloc Allocate space for sparse matrix
spdiags Extract nonzero diagonals and create sparse band and diagonal matrices
speye Sparse identity matrix
Manipulation
issparse Determine whether input is sparse
Reordering Algorithms
dissect Nested dissection permutation
bicgstabl Solve system of linear equations — stabilized biconjugate gradients (l) method
Structural Analysis
sprank Structural rank
Analyze Structure
centrality Measure node importance
Matrix Representation
adjacency Graph adjacency matrix
Node Information
degree Degree of graph nodes
Visualization
plot Plot graph nodes and edges
Other
GraphPlot Graph plot for directed and undirected graphs
Computational Geometry
Triangulation Representation
Triangulation Object
triangulation Triangulation in 2-D or 3-D
Delaunay Triangulation
Basic Delaunay Triangulations
delaunay Delaunay triangulation
Spatial Search
triangulation Triangulation in 2-D or 3-D
delaunayTriangulation Delaunay triangulation in 2-D and 3-D
Bounding Regions
Basic Bounding Regions
boundary Boundary of a set of points in 2-D or 3-D
Voronoi Diagram
voronoi Voronoi diagram
Elementary Polygons
Simple Polygons
boundaryshape Create polyshape from 2-D triangulation
inpolygon Points located inside or on edge of polygonal region
Polyshape Object
Create and Modify Polyshape
polyshape 2-D polygons
Geometric Quantities
area Area of polyshape
Boolean Operations
intersect Intersection of polyshape objects
Log Plots
loglog Log-log scale plot
Function Plots
fplot Plot expression or function
Other
LineSpec (Line Specification) Line specification
Bubble Charts
bubblechart Bubble chart
Geographic Plots
geoplot Plot line in geographic coordinates
Polar Plots
Plot Data
polarplot Plot line in polar coordinates
Contour Plots
contour Contour plot of matrix
contourf Filled 2-D contour plot
Vector Fields
quiver Quiver or vector plot
Volume Visualization
Scalar Volume Data
contourslice Draw contours in volume slice planes
Polygons
fill Filled 2-D polygons
Animation
movie Play recorded movie frames
Annotations
text Add text descriptions to data points
gtext Add text to figure using mouse
Axes Appearance
Axes Limits and Aspect Ratios
xlim Set or query x-axis limits
Multiple Plots
hold Retain current plot when adding new plots
Colormaps
Colormaps and Colorbars
colormap View and set current colormap
Colormap Adjustments
brighten Brighten or darken colormap
Colorspaces
hsv2rgb Convert HSV colors to RGB
Predefined Colormaps
parula Parula colormap array
Images
Display Image
imshow Display image
imtile Combine multiple image frames into one rectangular tiled image
cmunique Eliminate duplicate colors in colormap; convert grayscale or truecolor image to indexed image
Graphics Objects
Graphics Object Properties
get Query graphics object properties
Object Containers
hggroup Create group object
Graphics Performance
drawnow Update figures and process callbacks
Functions
Function Basics
function Declare function name, inputs, and outputs
Check Arguments
narginchk Validate number of input arguments
Arguments Block
arguments Declare function argument validation
Validation Functions
Numeric Value Attribute Validation
mustBePositive Validate that value is positive
Comparison Validation
mustBeGreaterThan Validate that value is greater than another value
mustBeText Validate that value is string array, character vector, or cell array of character vectors
Size Validation
mustBeNonempty Validate that value is nonempty
Error Handling
try, catch Execute statements and catch resulting errors
Classes
Class Syntax Guide
class Class of object
Class Definition
Class File Organization
classdef Class definition keywords
Properties
Property Information
properties Class property names
Validation Functions
Numeric Value Attribute Validation
Comparison Validation
mustBeGreaterThan Validate that value is greater than another value
mustBeText Validate that value is string array, character vector, or cell array of character vectors
Size Validation
Other
dynamicprops Superclass for classes that support dynamic properties
Methods
methods Class method names
Handle Classes
isequal Determine array equality
eq Determine equality
Other
handle Superclass of all handle classes
matlab.mixin.SetGetExactNames Require exact name match for set and get methods
Events
events Event names
Class Hierarchies
superclasses Names of superclasses
Enumerations
enumeration Class enumeration members and names
Class Customization
Object Indexing
numArgumentsFromSubscript Number of arguments for customized indexing methods
Object Arrays
empty Create empty array of specified class
Other
meta.class Describe MATLAB class
System Objects
Use System Objects
step Run System object algorithm
release Release resources and allow changes to System object property values and input characteristics
setProperties Set property values using name-value pairs when creating System object
isInputDataTypeMutableImpl Set whether System object input data type can change
processInputSpecificationChangeImpl Perform actions when input size, complexity, or data type change
Update Syntax
sysobjupdate Update custom System object to latest syntax
Other
matlab.System Base class for System objects
pathtool Open Set Path dialog box to view and change search path
File Operations
dir List folder contents
File Compression
zip Compress files into zip file
filemarker Character to separate file name from local or nested function name
Programming Utilities
Evaluate Expressions
eval Evaluate MATLAB expression
Protect Code
pcode Create content-obscured, executable files
Handle Exceptions
try, catch Execute statements and catch resulting errors
Axes
uiaxes Create UI axes for plots in apps
Components
Common Components
uibutton Create push button or state button component
uibuttongroup Create button group to manage radio buttons and toggle buttons
Figure Tools
uicontextmenu Create context menu component
Instrumentation Components
uigauge Create gauge component
Extensible Components
uihtml Create HTML UI component
scroll Scroll to location within container, tree, list box, or text area
uiopen Open file selection dialog box and load selected file into workspace
figure-Based Apps
Components
axes Create Cartesian axes
uibuttongroup Create button group to manage radio buttons and toggle buttons
Layout
align Align UI components and graphics objects
File System
uigetfile Open file selection dialog box
uiopen Open file selection dialog box and load selected file into workspace
Other
dialog Create empty modal dialog box
Control Flow
uiwait Block program execution and wait to resume
Syntax Checking
checkcode Check MATLAB code files for possible problems
Release Compatibility
codeCompatibilityReport Create code compatibility report
Projects
Create and Export Projects
currentProject Get current project
Setup Projects
addFile Add file or folder to project
Project Objects
matlab.project.Project Project object
Testing Frameworks
Script-Based Unit Tests
assert Throw error if condition false
run Run TestSuite array using TestRunner object configured for text output
run Run TestSuite array using TestRunner object configured for text output
Mocking Framework
General Purpose
matlab.mock.TestCase TestCase to write tests with mocking framework
matlab.mock.actions.ThrowException Throw exception when method is called or when property is set or accessed
Toolbox Distribution
Toolbox Files
matlab.addons.toolbox.packageToolbox Package toolbox project
Code Dependencies
matlab.codetools.requiredFilesAndProducts List dependencies of MATLAB program files
Settings API
matlab.settings.FactoryGroup.createToolboxGroup Create FactoryGroup root object for toolbox
matlab.settings.mustBeLogicalScalar Validate that setting value is logical array with one element
matlab.settings.mustBeNumericScalar Validate that setting value is numeric array with one element
matlab.settings.mustBeStringScalar Validate that setting value is string array with one element
matlab.settings.mustBeIntegerScalar Validate that setting value is integer array with one element
matlab.settings.loadSettingsCompatibilityResults Get results of upgrading personal settings of toolbox for specific version
FactoryGroup Group of factory settings and factory subgroup objects
Other
tabularTextDatastore Datastore for tabular text files
Spreadsheets
Read and Write Tables or Timetables
readtable Create table from file
Other
spreadsheetDatastore Datastore for spreadsheet files
Images
im2java Convert image to Java image
Scientific Data
NetCDF Files
Read or Write NetCDF Files
nccreate Create variable in NetCDF file
ncdisp Display contents of NetCDF data source in Command Window
File Operations
netcdf.abort Revert recent netCDF file definitions
Dimensions
netcdf.defDim Create netCDF dimension
Groups
netcdf.defGrp Create group in NetCDF file
Variables
netcdf.defVarFill Define fill parameters for NetCDF variable
Attributes
netcdf.copyAtt Copy attribute to new location
Utilities
netcdf.getConstant Return numeric value of named constant
HDF5 Files
High-Level Functions
Low-Level Functions
Library (H5)
Attribute (H5A)
H5A.close Close specified attribute
Dataset (H5D)
H5D.close Close dataset
Error (H5E)
H5E.clear Clear error stack
File (H5F)
H5F.close Close HDF5 file
Group (H5G)
H5G.close Close group
Identifier (H5I)
H5I.dec_ref Decrement reference count
Link (H5L)
H5L.copy Copy link from source location to destination location
H5L.visit_by_name Recursively iterate through links in group specified by location and group name
MATLAB (H5ML)
H5ML.compare_values Numerically compare two HDF5 values
Object (H5O)
H5O.close Close object
H5O.get_comment_by_name Get comment for object specified by location and object name
H5O.set_comment_by_name Set comment for object specified by location and object name
H5P.get_sym_k Return size of B-tree 1/2 rank and leaf node 1/2 size
Reference (H5R)
H5R.create Create reference
Dataspace (H5S)
H5S.copy Create copy of data space
H5T.set_pad Set padding type for least and most significant bits
HDF4 Files
High-Level Functions
hdfinfo Information about HDF4 or HDF-EOS file
Low-Level Functions
matlab.io.hdf4.sd Interact directly with HDF4 multifile scientific data set (SD) interface
Other
hdfan Gateway to HDF multifile annotation (AN) interface
FITS Files
High-Level Functions
fitsdisp Display FITS metadata
Low-Level Functions
File Access
Image Manipulation
createImg Create FITS image
Keywords
readCard Header record of keyword
readKey Keyword
movNamHDU Move to first HDU having specific type and keyword values
Image Compression
imgCompress Compress HDU from one file into another
Utilities
getConstantValue Numeric value of named constant
Band-Interleaved Files
multibandread Read band-interleaved data from binary file
cdfepoch Convert date text or serial date number to CDF formatted dates
playblocking Play audio from audioplayer object, hold control until playback completes
Record Audio
recordblocking Record audio to audiorecorder object, hold control until recording completes
Play Sound
xmlread Read XML document and return Document Object Model node
matfile Access and change variables in MAT-file without loading file into memory
openvar Open workspace variable in Variables editor or other graphical editing tool
TCP/IP Communication
tcpclient Create TCP/IP client connection with TCP/IP server
configureTerminator Set terminator for ASCII string communication with remote host over TCP/IP
configureCallback Set callback function and trigger condition for communication with remote host over TCP/IP
readline Read line of ASCII string data from remote host over TCP/IP
flush Clear buffers for communication with remote host over TCP/IP
Bluetooth Communication
bluetoothlist Scan nearby Bluetooth Classic devices
configureTerminator Set terminator for ASCII string communication with Bluetooth device
configureCallback Set callback function and trigger condition for communication with Bluetooth device
read Read characteristic or descriptor data on a Bluetooth Low Energy peripheral device
write Write data to a characteristic or descriptor on a Bluetooth Low Energy peripheral device
Web Access
Web
webread Read content from RESTful web service
FTP
ftp Object to connect to FTP server and access its files
JSON Format
jsondecode Decode JSON-formatted text
configureTerminator Set terminator for ASCII string communication with serial port
configureCallback Set callback function and trigger condition for communication with serial port device
Tall Arrays
Creation and Evaluation
tall Create tall array
gather Collect tall array into memory after executing queued operations
write Write tall array to local and remote locations for checkpointing
Determine Type
istall Determine if input is tall array
matlab.tall.blockMovingWindow Apply moving window function and block reduction to padded blocks of data
MapReduce
mapreduce Programming technique for analyzing data sets that do not fit in memory
Large MAT-Files
matfile Access and change variables in MAT-file without loading file into memory
Parquet Files
parquetread Read columnar data from a Parquet file
Memory Mapping
memmapfile Create memory map to a file
Preprocessing Data
Missing Data and Outliers
ismissing Find missing values
Descriptive Statistics
Basic Statistics
min Minimum elements of an array
var Variance
cov Covariance
xcorr Cross-correlation
xcov Cross-covariance
Cumulative Statistics
cummax Cumulative maximum
Moving Statistics
movmad Moving median absolute deviation
Visual Exploration
Plot Editing Tools
plotedit Interactively edit and annotate plots
Built-In Interactions
panInteraction Pan interaction
rulerPanInteraction Ruler-pan interaction
Interaction Modes
pan Pan view of graph interactively
Property Linking
linkdata Automatically update charted data