How to create cell followed by uniform distribution?

1 回表示 (過去 30 日間)
SM
SM 2020 年 7 月 13 日
コメント済み: SM 2020 年 7 月 13 日
I need to create a cell of size n*m which will follow uniform distribution. I can easily create a cell of size 3*2 by the following data set:
a=3; b=8; n=3; m=2;
A={{round((b-a).*rand(1,3) + a)} {round((b-a).*rand(1,3) + a)}; {round((b-a).*rand(1,3) + a)} {round((b-a).*rand(1,3) + a)}; {round((b-a).*rand(1,3) + a)} {round((b-a).*rand(1,3) + a)}};
it resuts
A=
3×2 cell array
{1×1 cell} {1×1 cell}
{1×1 cell} {1×1 cell}
{1×1 cell} {1×1 cell}
where A{1,1}=[8 4 6], A{1,2}=[4 6 3].......etc. How can I generate such cell with less effort for larger size because creating 10*20 size cell in this way is almost impossible?

採用された回答

madhan ravi
madhan ravi 2020 年 7 月 13 日
z = arrayfun(@(x){round((b-a).*rand(1,3) + a)},1:3*2,'un',0);
A = reshape(z, 3, [])
  1 件のコメント
SM
SM 2020 年 7 月 13 日
Thank you! You save my time!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by