subs
Symbolic substitution
Syntax
Description
Substitute Symbolic Scalar Variables and Functions
returns a copy of snew = subs(s,match,replacement)s, replacing all occurrences of
match with replacement, and then evaluates
s. Here, s is an expression of symbolic scalar
variables or a symbolic function, and match specifies the symbolic
scalar variables or symbolic function to be substituted.
If
matchandreplacementare both vectors or cell arrays of the same size,subsreplaces each element ofmatchwith the corresponding element ofreplacement.If
matchis a scalar, andreplacementis a vector or matrix, thensubs(s,match,replacement)replaces all instances ofmatchinswithreplacement, performing all operations element-wise. All constant terms insare replaced with the constant multiplied by a vector or matrix of all ones.
returns a copy of snew = subs(s,replacement)s, replacing all occurrences of the default
symbolic scalar variable in s with replacement,
and then evaluates s. The default variable is defined by symvar(s,1).
Substitute Symbolic Matrix Variables and Functions
returns a copy of sMnew = subs(sM,matchM,replacementM)sM, replacing all occurrences of
matchM with replacementM, and then evaluates
sM. Here, sM is an expression, equation, or
condition involving symbolic matrix variables and matrix functions, and
matchM specifies the symbolic matrix variables and matrix functions
to be substituted. The substitution values replacementM must have the
same size as matchM. (since R2021b)
returns a copy of sMnew = subs(sM,replacementM)sM, replacing all occurrences of the default
symbolic matrix variable in sM with
replacementM, and then evaluates sM. (since R2021b)
Examples
Input Arguments
Tips
subs(s,__)does not modifys. To modifys, uses = subs(s,__).If
sis a univariate polynomial andreplacementis a numeric matrix, usepolyvalm(sym2poly(s),replacement)to evaluatesas a matrix. All constant terms are replaced with the constant multiplied by an identity matrix.