%% Customize Abbreviation Variables
% Solve a quadratic equation.

syms a b c x
solutions = solve(a*x^2 + b*x + c == 0, x)

% Use syms to create the symbolic variable s, and then replace common subexpressions in the result with this variable.

syms s
[abbrSolutions,s] = subexpr(solutions,s)

% Alternatively, use 's' to specify the abbreviation variable.

[abbrSolutions,s] = subexpr(solutions,'s')

% Both syntaxes overwrite the value of the variable s with the common subexpression. Therefore, you cannot, for example, substitute s with some value.

subs(abbrSolutions,s,0)

% To avoid overwriting the value of the variable s, use another variable name for the second output argument.

syms s
[abbrSolutions,t] = subexpr(solutions,'s')
subs(abbrSolutions,s,0)

%
% Copyright 2006 The MathWorks, Inc.