# num2cell

Returns a cell array after converting a complex, 2D matrix, scalar or string input.

## Syntax

R = num2cell(m)

R = num2cell(m, d)

## Inputs

m
Type: complex | number | double | integer | matrix | string
d (optional)
Dimension that specifies the number of rows or columns in the output, R. A value of 1 will result in R having one row. A value of 2 will result in R having one column.
Type: Positive integer

R
Type: cell

## Examples

Converts a matrix to a cell:
R = num2cell([1, 2, 3; 4, 5, 6])
R =
{
[1,1] 1
[1,2] 2
[1,3] 3
[2,1] 4
[2,2] 5
[2,3] 6
}
Converts a matrix to a cell, with the output having one row:
R = num2cell([1, 2, 3; 4, 5, 6], 1)
R =
{
[1,1] [Matrix] 2 x 1
1
4
[1,2] [Matrix]
2
5
[1,3] [Matrix] 2 x 1
3
6}
Converts a matrix to a cell with the output having one column:
R = num2cell([1, 2, 3; 4, 5, 6], 2)
R =
{
[1,1] [Matrix] 1 x 3
1  2  3
[2,1] [Matrix] 1 x 3
4  5  6
}