symssyms x;
syms a b c % Create multiple symbolic variables in one command
A = sym('a',[1,20]) % Create the variables a1, ..., a20
syms a b c x
f = a*x^2+b*x+c
subs(f,x,5) % Assign a value to x
subs(f,[x a b c],[5 1 2 3]) % Assign a list of values to a, b, c and x
expand(S): Multiples out all the portions of the expression or equationsyms x
expand((x-3)*(x+6))
factor(S): Factors the expression or equation
syms x
factor(x^3-1)
collect(S): Collects like termssyms x
S = 2*(x+3)^2 + x^2 + 6*x + 9;
collect(S)
simplify(S): Simplifies in accordance with MuPad's simplification rulessyms x
simplify(exp(log(x)))
numden(S): Finds the numerator of an expression; this function is not valid for equationssyms x
numden((x-5)/(x+5))
[num,den] = numden(S): Finds bot the numerator and the denominator of an expressionsyms x
[num,den] = numden((x-5)/(x+5))
solve(S))¶solve(S): Solves an expression with a single variablesyms x
solve(x-5)
solve(S): Solves an equation with a single variablesyms x
solve(x^2-2==5)
solve(S): Solves an equation whose solutions are complex numberssyms x
solve(x^2==-5)
solve(S): Solves an equation with more than one variable for x or the closest variable to xsyms x y
solve(y==x^2+2)
solve(S,y): Solves an equation with more than one variable for a specified variablesyms x y
solve(y+6*x,x)
solve(S1,S2,S3): Solves a system of equations and presents the solutions as a structure arraysyms x y z
one = 3*x+2*y-z==10;
two = -x+3*y+2*z==5;
three = x-y-z==-1;
solve(one,two,three)
[A,B,C] = solve(S1,S2,S3): Solves a system of equations and assigns the solutions to user-defined variable names; displays the results alphabeticallysyms x y z
one = 3*x+2*y-z==10;
two = -x+3*y+2*z==5;
three = x-y-z==-1;
[A,B,C] = solve(one,two,three)
ezplot(f): Plots a symbolic expression, equation, or function $f$. By default, ezplot plots a univariate expression or function over the range $[-2\pi,2\pi]$ or over a subinterval of this range. If $f$ is an equation or function of two variables, the default range for both variables, the default range for both variables is $[-2\pi,2\pi]$ or over a subinterval of this range.syms x y
f(x,y)=sin(x+y)*sin(x*y);
ezplot(f)
ezplot(f,[min,max]): plots $f$ over the specified range. If $f$ is a univariate expression or function, then $[min,max]$ specifies the range for that variable along the abscissa. If $f$ is an equation or function of two variables, then $[min,max]$ specifies the range for both variables along both the abscissa and the ordinate.syms x
y=x^2-2;
ezplot(y,[-10,10])
ezplot('x^2+y^2=1',[-1.5,1.5])
ezplot(f,[xmin,xmax,ymin,ymax]): Plots $f$ over the specified ranges along the abscissa and the ordinate.syms x
a=1/x;
ezplot(a,[-2,2,-3,3])
diff(f): Returns the derivative of the expression $f$ with respect to the default independent variable.syms x z
y = x^3+z^2;
diff(y)
diff(f,'t'): Returns the derivative of the expression $f$ with respect to the variable $t$.syms x z
y = x^3+z^2;
diff(y,'z')
diff(f,n): Returns the $n$th derivative of the expression $f$ with respect to the default independent variable.syms x z
y = x^3+z^2;
diff(y,2)
diff(f,'t',n) : Returns the $n$th derivative of the expression $f$ with respect to the variable $t$.syms x z
y = x^3+z^2;
diff(y,'z',2)
int(f): Returns the integral of the expression $f$ with respect to the default independent variable.syms x z
y = x^3+z^2;
int(y)
int(f,'t'): Returns the integral of the expression $f$ with respect to the variable $t$.syms x z
y = x^3+z^2;
int(y,'z')
int(f,a,b): Returns the integral of the expression $f$ with respect to the default independent variable, between the numeric bounds $a$ and $b$.syms x z
y = x^3+z^2;
int(y,2,3)
int(f,'t',a,b): Returns the integral of the expression $f$ with respect to the variable $t$, between the numeric bounds $a$ and $b$.syms x z
y = x^3+z^2;
int(y,'z',2,3)
int(f,'t','a','b'): Returns the integral of the expression $f$ with respect to the variable $t$, between the symbolic bounds $a$ and $b$.syms x z
y = x^3+z^2;
int(y,'z','a','b')
g = matlabFunction(f): Converts $f$ to a MATLAB function with the handle $g$. $f$ can be a symbolic expression, function, or a vector of symbolic expressions or functions.syms x y
s = sqrt(x^2+y^2);
g = matlabFunction(sin(s)/s)
syms x y
f(x,y) = sqrt(x^2+y^2);
g = matlabFunction(f)