主要内容

Supported Operations on Expressions

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, complex or 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
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
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
gamma — Derivative of gamma(x) supported only for nonnegative x.
Real/Complex Operations
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 createArray(dims,"like",Expression), createArray(dims,"like",Expression,FillValue=numeric), and createArray(dims,"like",Expression,FillValue=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 cast(Expression,"double"), cast(Expression,"single"), cast(Expression,"logical"), and cast(A,"like",Expression), where A can be numeric or an expression object.
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