How do I create an empty cell array of given dimensions?

I want to assign double matrices into a 3-D cell array. The dimensions of the cell array need to be equivalent to variable1 x variable2 x variable 3. How do I initially create the empty array?

 Accepted Answer

More Answers (1)

Wouldn't it be nice if documentation for that function existed?

7 Comments

You know it is in "help cell" or "doc cell" right?
Nope! I tried that before I went to Google. That got me a page about cell arrays in general that told me to use braces to create a cell array. Some MVP you turned out to be!
>> help cell
cell Create cell array.
cell(N) is an N-by-N cell array of empty matrices.
cell(M,N) or cell([M,N]) is an M-by-N cell array of empty
matrices.
cell(M,N,P,...) or cell([M N P ...]) is an M-by-N-by-P-by-...
cell array of empty matrices.
Sorry, I used doc cell, and that is not what I saw. I saw:
cell
Cell array
Description
A cell array is a data type with indexed data containers called cells, where each cell can contain any type of data. Cell arrays commonly contain either lists of text, combinations of text and numbers, or numeric arrays of different sizes. Refer to sets of cells by enclosing indices in smooth parentheses, (). Access the contents of cells by indexing with curly braces, {}.
Creation
When you have data to put into a cell array, create the array using the cell array construction operator, {}.
C = {1,2,3;
'text',rand(5,10,2),{11; 22; 33}}
C=2×3 cell
{[ 1]} {[ 2]} {[ 3]}
{'text'} {5x10x2 double} {3x1 cell}
You also can use {} to create an empty 0-by-0 cell array.
C = {}
C =
0x0 empty cell array
I hope you can see why I thought it was undocumented. For everything else I've ever used doc for, doc and help returned the same information. They should fix the doc entry. Put the babble about braces after the description of the function.
If you look towards the end section of the "doc cell" page ... Yes. It does not look like the best way.
I've given the page two stars and explained the issue.

Sign in to comment.

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!