フィルターのクリア

How to populate a cell array?

27 ビュー (過去 30 日間)
Ananya Malik
Ananya Malik 2016 年 11 月 10 日
コメント済み: Ananya Malik 2016 年 11 月 10 日
I want to create an array with 10 rows and each row should contain a [5x2] matrix.
I also want to know
(a)inserting data into it
(b)accessing the data.
Can anyone help? TIA.

採用された回答

Guillaume
Guillaume 2016 年 11 月 10 日
Which of your points is not covered by the documentation?
There are many ways of creating a cell array. Which one is most appropriate entirely depends what form the content comes in before it becomes a cell array
c = squeeze(num2cell(rand(5, 2, 10), [1 2])); %will create a 10x1 cell array of 5x2 matrices
c = arrayfun(@(~) rand(5,2), (1:10)', 'UniformOutput', false); %another way
c = mat2cell(rand(5*10, 2), ones(1,10)*5, 2); %another way
c = cell(10, 1); for idx = 1:10; c{idx} = rand(5,2); end; %and another way
%... and many more
  1 件のコメント
Ananya Malik
Ananya Malik 2016 年 11 月 10 日
Thank you sir. The fourth solution looks pretty simple.

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by