| Contents | Index |
syms var1 ... varN
syms var1 ... varN set
syms var1 ... varN clear
syms f(arg1,...,argN)
syms var1 ... varN creates symbolic variables var1 ... varN.
syms var1 ... varN set creates symbolic variables var1 ... varN and states that these variables belong to set.
syms var1 ... varN clear removes assumptions previously set on symbolic variables var1 ... varN.
syms f(arg1,...,argN) creates the symbolic function f and symbolic variables arg1,...,argN representing the input arguments of f.
For compatibility with previous versions, syms var1 ... varN unreal is equivalent to syms var1 ... varN clear.
In functions and scripts, do not use syms to create symbolic variables with the same names as MATLAB functions. For these names MATLAB does not create symbolic variables, but keeps the names assigned to the functions. If you want to create a symbolic variable with the same name as some MATLAB function inside a function or a script, use sym. For example:
alpha = sym('alpha')clear x does not clear the symbolic object of its assumptions, such as real, positive, or any assumptions set by assume. To remove assumptions, use one of these options:
syms x clear removes assumptions from x without affecting any other symbolic variables.
reset(symengine) resets the symbolic engine and therefore removes assumptions on all variables. The variables themselves remain in the MATLAB workspace.
clear all removes all objects in the MATLAB workspace and resets the symbolic engine.
Create symbolic variables x and y using syms:
syms x y
Create symbolic variables x and y, and assume that they are real:
syms x y real
To see assumptions set on x and y, use assumptions:
assumptions(x) assumptions(y)
ans = x in R_ ans = y in R_
Clear the assumptions that x and y are real:
syms x y clear assumptions
ans = [ empty sym ]
Create a symbolic function f that accepts two arguments, x and y:
syms f(x, y)
Specify the formula for this function:
f(x, y) = x + 2*y
f(x, y) = x + 2*y
Compute the function value at the point x = 1 and y = 2:
f(1, 2)
ans = 5
Create symbolic function f and specify its formula by this symbolic matrix:
syms x f(x) = [x x^2; x^3 x^4];
Compute the function value at the point x = 2:
f(2)
ans = [ 2, 4] [ 8, 16]
Now compute the value of this function for x = [1 2; 3 4]. The result is a cell array of symbolic matrices:
y = f([1 2; 3 4])
y =
[2x2 sym] [2x2 sym]
[2x2 sym] [2x2 sym]To access the contents of each cell in a cell array, use braces:
y{1}ans = [ 1, 2] [ 3, 4]
y{2}ans = [ 1, 8] [ 27, 64]
y{3}ans = [ 1, 4] [ 9, 16]
y{4}ans = [ 1, 16] [ 81, 256]
syms is a shortcut for sym. This shortcut lets you create several symbolic variables in one function call. Alternatively, you can use sym and create each variable separately:
var1 = sym('var1');
...
varN = sym('varN');sym also lets you create real variables or positive variables. It also lets you clear assumptions set on a variable.
assume and assumeAlso provide more flexibility for setting assumptions on variable.
When creating a symbolic function, use syms to create arg1,...,argN as symbolic variables. Then use the assignment operation to create the symbolic function f, for example:
syms x y f(x, y) = x + y
assume | assumeAlso | assumptions | clear all | reset | sym | symfun | symvar

See how symbolic computations can help you find analytical solutions to math and engineering problems.
Get free kit| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |