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?
採用された回答
その他の回答 (1 件)
Al in St. Louis
2020 年 5 月 8 日
0 投票
Wouldn't it be nice if documentation for that function existed?
7 件のコメント
Fangjun Jiang
2020 年 5 月 8 日
You know it is in "help cell" or "doc cell" right?
Al in St. Louis
2020 年 5 月 8 日
編集済み: Al in St. Louis
2020 年 5 月 8 日
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!
Fangjun Jiang
2020 年 5 月 8 日
>> 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.
Al in St. Louis
2020 年 5 月 8 日
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
Al in St. Louis
2020 年 5 月 8 日
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.
Fangjun Jiang
2020 年 5 月 8 日
If you look towards the end section of the "doc cell" page ... Yes. It does not look like the best way.
Al in St. Louis
2020 年 5 月 8 日
I've given the page two stars and explained the issue.
カテゴリ
ヘルプ センター および File Exchange で Matrix Indexing についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!