subs
Symbolic substitution
Syntax
Description
Substitute Symbolic Scalar Variables and Functions
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 - matchand- replacementare both vectors or cell arrays of the same size,- subsreplaces each element of- matchwith the corresponding element of- replacement.
- If - matchis a scalar, and- replacementis a vector or matrix, then- subs(s,match,replacement)replaces all instances of- matchin- swith- replacement, performing all operations element-wise. All constant terms in- sare replaced with the constant multiplied by a vector or matrix of all ones.
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
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)
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 modify- s. To modify- s, use- s = subs(s,__).
- If - sis a univariate polynomial and- replacementis a numeric matrix, use- polyvalm(sym2poly(s),replacement)to evaluate- sas a matrix. All constant terms are replaced with the constant multiplied by an identity matrix.