Contenuto principale

Supported Operations on Expressions

R2026b

MATLAB® uses an internal expression object to represent symbolic variables for automatic differentiation calculations. This section lists the supported operations on expressions for automatic differentiation.

Currently, sparse values are not supported.

Arithmetic Operations
plus
uplus
minus
uminus
times
rdivide
ldivide
mtimes
pagemtimes
dot
sum — No support for nanflag or outputtype options
mean — No support for nanflag or outputtype or Weights options
accumarray — Supports only accumarray(ind,data,sz) where ind and data are column vectors of equal length and ind and sz are numeric. sz is the output size and is a required argument.
prod — No support for nanflag or outputtype options
trace
cumsum — No support for nanflag option
cumprod — No support for nanflag option
diff
power
transpose
ctranspose
pagetranspose
pagectranspose
Matrix Indexing
subsref
subsasgn
Indexing (optimized subsref/subsasgn)
Matrix Combining and Reshaping
cat
vertcat
horzcat
reshape
repmat
diag
squeeze
permute
colon
sign
trace
circshift
shiftdim — Supports only one-output syntaxes
Trigonometric, Exponential, and Related Functions
sqrt
norm — First input must be a vector, second input must be a positive number or "Inf". In particular, norm(A) for a non-vector matrix A is not supported, nor is norm(A,p) nor norm(vector,"fro").
sin
cos
tan
csc
sec
cot
sind
cosd
tand
cotd
secd
cscd
asin
acos
atan
acsc
asec
acot
atan2
asind
acosd
atand
acscd
asecd
acotd
atan2d
sinh
cosh
tanh
csch
sech
coth
asinh
acosh
atanh
acsch
asech
acoth
deg2rad
rad2deg
exp
log
erf
erfinv
erfc
erfcinv
erfcx
gamma — Derivative of gamma(x) supported only for nonnegative x.
psi
Real/Complex Operations
complex
abs
conj
imag
angle
real
reallog
realsqrt
sign
realpow
Discrete Operations
ceil
fix
floor
round — Supports only one-input syntax
eps — Supports only eps("like",x)
max
min
sort — Supports only sort(x) and sort(x,dim); does not support option strings or other arguments.
Array Queries (return doubles)
length
ndims
numel
size
Data Creation
false
true
flintmax
realmax
realmin
eye — Does not support the typename syntax
inf — Does not support the typename syntax
nan — Does not support the typename syntax
ones — Does not support the typename syntax
zeros — Does not support the typename syntax
rand — Does not support the typename syntax
randi — Does not support the typename syntax
randn — Does not support the typename syntax

createArray — Supports cases where the "like" name-value argument is specified as an expression.

  • FillValue can be specified as a numeric value or an expression.

  • The resulting gradients are zero, except when the gradient is with respect to a FillValue that is an expression.

The syntax createArray(dims,"like",numeric,FillValue=expression) throws an error because casting from expression to numeric is not supported.

Advanced Matrix Operations

mpower — Supports these cases:

  • scalar^scalar, either or both scalars can be expressions or numeric values.

  • matrix^scalar, where scalar is a nonnegative integer and not an expression.

In particular, scalar^matrix is not supported.

prod — No support for nanflag or outputtype options
mldivide — Supports division by scalar only
mrdivide — Supports division by scalar only
vecnorm
kron
Logical and Comparison
all
and
any
eq
ge
gt
le
lt
ne
not
or
xor
Data Types and Conversion

cast — Supports these cases:

  • cast(expression,typename), where typename is "double", "single", or "logical"

  • cast(A,"like",expression), where A is a numeric value or an expression object.

full
sparse — Supports only sparse(A)
double
logical
single
Comparison Tests
isequal
isequaln
isfinite
isempty
isinf
isnan
iscolumn
ismatrix
isrow
isscalar
isvector
Programming Statements
for loop
if/else

See Also

Topics