Back to Symbolic Mathematics

sym

Create symbolic variable or expression

Syntax

x = sym(s)
x = sym(n)

Description

Creates a symbolic variable from a string name or converts a number to a symbolic number. Supports both function syntax sym('x') and command syntax sym x. When given a simple variable name, creates a symbolic variable. When given an expression string, parses it into a symbolic expression.

Parameters

NameDescription
sVariable name (string) or numeric value to convert

Returns

Symbolic variable or expression

Examples

Try It
>> x = sym('x')
x
Try It
>> sym x
x
Try It
>> f = sym('x^2 + 2*x + 1')
x^2 + 2*x + 1
Try It
>> half = sym(1/2)
1/2

See Also