# Documentation

### This is machine translation

Translated by
Mouse over text to see original. Click the button below to return to the English verison of the page.

# cell

Create cell array

## Syntax

• ``C = cell(n)``
example
• ``C = cell(sz1,...,szN)``
example
• ``C = cell(sz)``
example
• ``D = cell(obj)``
example

## Description

example

````C = cell(n)` returns an `n`-by-`n` cell array of empty matrices.```

example

````C = cell(sz1,...,szN)` returns a `sz1`-by-...-by-`szN` cell array of empty matrices where `sz1,...,szN` indicate the size of each dimension. For example, `cell(2,3)` returns a 2-by-3 cell array.```

example

````C = cell(sz)` returns a cell array of empty matrices where size vector `sz` defines `size(C)`. For example, `cell([2 3])` returns a 2-by-3 cell array.```

example

````D = cell(obj)` converts a Java® array or .NET `System.String` or `System.Object` array into a MATLAB® cell array.```

## Examples

collapse all

Create a 3-by-3 cell array of empty matrices.

```C = cell(3) ```
```C = 3×3 cell array [] [] [] [] [] [] [] [] [] ```

Create a 3-by-4-by-2 cell array of empty matrices.

```C = cell(3,4,2); size(C) ```
```ans = 3 4 2 ```

Create a cell array of empty matrices that is the same size as an existing array.

```A = [7 9; 2 1; 8 3]; sz = size(A); C = cell(sz) ```
```C = 3×2 cell array [] [] [] [] [] [] ```

It is a common pattern to combine the previous two lines of code into a single line.

```C = cell(size(A)); ```

Convert an array of `java.lang.String` objects into a cell array.

```X = java_array('java.lang.String', 3); X(1) = java.lang.String('one'); X(2) = java.lang.String('two'); X(3) = java.lang.String('three'); D = cell(X) ```
```D = 'one' 'two' 'three' ```

Convert a .NET array of `System.Double` objects into a cell array.

```N = NET.createArray('System.Double[]',2); N(1) = [13 7 30]; N(2) = 42; D = cell(N) ```
```D = [1x3 double] [42] ```

## Input Arguments

collapse all

Size of a square cell array, specified as an integer value.

• If `n` is `0`, then `C` is an empty cell array.

• If `n` is negative, then it is treated as `0`.

Data Types: `double` | `single` | `int8` | `int16` | `int32` | `int64` | `uint8` | `uint16` | `uint32` | `uint64`

Size of each dimension, specified as separate arguments of integer values.

• If the size of any dimension is `0`, then `C` is an empty cell array.

• If the size of any dimension is negative, then it is treated as `0`.

• Beyond the second dimension, `cell` ignores trailing dimensions with a size of 1. For example, `cell([3,1,1,1])` produces a 3-by-1 cell array of empty matrices.

Data Types: `double` | `single` | `int8` | `int16` | `int32` | `int64` | `uint8` | `uint16` | `uint32` | `uint64`

Size of each dimension, specified as a row vector of integer values. Each element of this vector indicates the size of the corresponding dimension.

• If the size of any dimension is `0`, then `C` is an empty cell array.

• If the size of any dimension is negative, then it is treated as `0`.

• Beyond the second dimension, `cell` ignores trailing dimensions with a size of 1. For example, `cell([3,1,1,1])` produces a 3-by-1 cell array of empty matrices.

Example: `sz = [2, 3, 4]` creates a 2-by-3-by-4 cell array of empty matrices.

Data Types: `double` | `single` | `int8` | `int16` | `int32` | `int64` | `uint8` | `uint16` | `uint32` | `uint64`

Input array, specified as:

• Java array or object

• .NET array of type `System.String` or `System.Object`

• Python sequence type

## Output Arguments

collapse all

Output array, returned as a cell array. Each cell contains an empty, 0-by-0 array of type `double`.

Converted array, returned as a cell array.

Each cell contains a MATLAB type closest to the Java or .NET type. For more information, see:

collapse all

### Tips

• Creating an empty array with the `cell` function, such as

`C = cell(3,4,2);`

is equivalent to assigning an empty array to the last index of a new cell array:

`C{3,4,2} = [];`