Command: syms
Command: syms x
Command: syms x y
Command: syms f(x)
Command: syms x asm
Command: syms x asm asm2

Create symbolic variables and symbolic functions.

This is a convenience function. For example:

syms x y z

instead of:

x = sym('x');
y = sym('y');
z = sym('z');

The last arguments can provide one or more assumptions (type or restriction) on the variable (see ‘sym’).

syms x y z positive
syms n positive even

Symfuns represent abstract or concrete functions. Abstract symfuns can be created with syms:

syms f(x)

Here x is created in the callers workspace, as a side effect.

Called without arguments, syms displays a list of all symbolic functions defined in the current workspace.

syms x y z
syms
  -| Symbolic variables in current scope:
  -|   x
  -|   y
  -|   z

Using syms to create a new symbol with different assumptions does not automatically replace instances of the old symbol in the caller’s workspace. For example suppose we make an absolute value expression:

syms x
f = abs (x)
  ⇒ f = (sym) │x│

If we make a new positive x, f still contains the old symbol:

syms x positive
simplify (f)
  ⇒ (sym) │x│

Note: this behaviour is slightly different from Matlab’s Symbolic Math Toolbox, which does change existing symbols. If that behaviour is desired, see ‘@sym/assume’ which modifies existing expressions in the caller’s workspace:

syms x
assume x positive
f
  ⇒ f = (sym) x

Caution: On Matlab, you may not want to use syms within functions. In particular, if you shadow a function name, you may get hard-to-track-down bugs. For example, instead of writing syms alpha use alpha = sym('alpha') within functions. [https://www.mathworks.com/matlabcentral/newsreader/view_thread/237730]

See also: sym, assume.

Package: symbolic