フィルターのクリア

Assigning matrix to cells

5 ビュー (過去 30 日間)
Di Zhu
Di Zhu 2016 年 5 月 20 日
コメント済み: Di Zhu 2016 年 5 月 20 日
Hello! I have preallocated the variable S with:S = cell(3,2); I want to assign the matrix [0 0 0] to each cell element, like this:
[0 0 0] [0 0 0]
[0 0 0] [0 0 0]
[0 0 0] [0 0 0]
I know that num2cell(zeros(3,2)) will give me
[0] [0]
[0] [0]
[0] [0]
Does anybody know if there is any way I can do this without using a for loop to assign [0 0 0] to each of the cell element? Thanks!

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2016 年 5 月 20 日
編集済み: Azzi Abdelmalek 2016 年 5 月 20 日
cellfun(@(x) zeros(1,3),cell(3,2),'un',0)
Or
mat2cell(zeros(3,2*3),ones(1,3),3*ones(1,2))
  1 件のコメント
Di Zhu
Di Zhu 2016 年 5 月 20 日
Thank you!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMultidimensional Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by