# sym2cell

Convert symbolic array to cell array

## Syntax

``C = sym2cell(S)``

## Description

example

````C = sym2cell(S)` converts a symbolic array `S` to a cell array `C`. The resulting cell array has the same size and dimensions as the input symbolic array.```

## Examples

collapse all

Convert a matrix of symbolic variables and numbers to a cell array.

Create the following symbolic matrix.

```syms x y S = [x 2 3 4; y 6 7 8; 9 10 11 12]```
```S =  $\left(\begin{array}{cccc}x& 2& 3& 4\\ y& 6& 7& 8\\ 9& 10& 11& 12\end{array}\right)$```

Convert this matrix to a cell array by using `sym2cell`. The size of the resulting cell array corresponds to the size of the input matrix. Each cell contains an element of the symbolic matrix `S`.

`C = sym2cell(S)`
```C=3×4 cell array {[x]} {[2 ]} {[3 ]} {[4 ]} {[y]} {[6 ]} {[7 ]} {[8 ]} {} {} {} {} ```

To access an element in each cell, use curly braces.

`[C{1,1:4}]`
`ans = $\left(\begin{array}{cccc}x& 2& 3& 4\end{array}\right)$`
`[C{1:3,1}]`
`ans = $\left(\begin{array}{ccc}x& y& 9\end{array}\right)$`

## Input Arguments

collapse all

Input symbolic array, specified as a symbolic vector, matrix, or multidimensional array. `S` also can be a scalar, that is, a symbolic number, variable, expression, or function.

## Output Arguments

collapse all

Resulting cell array, returned as a cell array such that ```size(C) = size(S)```. Each element of the input symbolic array `S` is enclosed in a separate cell.

## Version History

Introduced in R2016a