Substitutions

You can replace symbols you have defined by a value.
>> syms a b
>> y = 3*sin(a)+cos(b)

y =
    3*sin(a)+cos(b)
In the line below, the symbol $ a$ is replaced by the value 2.
>> y = subs(y,a,2)

y =
    3*sin(2)+cos(b)

>> subs(y,b,5)

ans =
    3.0116
Substitution of the value 2 for $ a$ and the value 5 for $ b$ can also be done at one sweep in the following way:
>> y = 3*sin(a)+cos(b)

y =
    3*sin(a)+cos(b)

>> subs(y,{a,b},{2,5})

ans =
    3.0116



Previous      Next      Up      Contents


Esteur 2010-03-22