cell2sym

Converts a cell array into a symbolic array.

Category: Symbolic Computations in MATLAB > Conversion Between Symbolic and Numeric

Syntax

S = cell2sym(C)

Converts each cell of C to a symbolic element.

Description

Each cell must hold a scalar. Numbers become exact symbolic numbers, text such as 'x' is parsed as a symbolic expression, and symbolic scalars are kept. Floating-point values are converted to nearby rational numbers, so 0.1 becomes 1/10 and 0.5 becomes 1/2.

The function is the inverse of sym2cell, and is useful to turn data read from text or tables into symbolic objects.

Input arguments

C
Cell array holding numbers, text or symbolic values.

Output arguments

S
Symbolic array with the same size as C.

Example

Numbers and text

S = cell2sym({1, 'a'; 2, 'b'})
cell2sym({0.1, 0.5})
class(S)
Output
S = 
[1, a]
[2, b]
ans = 
[1/10, 1/2]
ans = 'sym'

See also

sym2cell sym double str2sym