how to simplify the command line that generates cell array

1 ビュー (過去 30 日間)
jaah navi
jaah navi 2021 年 6 月 23 日
回答済み: Walter Roberson 2021 年 6 月 23 日
I am having C = 6×1 cell array
{2×1 double}
{2×1 double}
{2×2 double}
{2×2 double}
{2×3 double}
{2×3 double}
using C = {rand(2,1);rand(2,1);rand(2,2);rand(2,2);rand(2,3);rand(2,3);}
is there any simplified way to write the above command.

採用された回答

Walter Roberson
Walter Roberson 2021 年 6 月 23 日
No, there is no simplified way to write it. You can automate it in some ways, but the automated versions are more complex.
C = arrayfun(@(N) rand(2,N), repelem((1:3).',2), 'uniform', 0)
C = 6×1 cell array
{2×1 double} {2×1 double} {2×2 double} {2×2 double} {2×3 double} {2×3 double}

その他の回答 (0 件)

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by