gpt4 book ai didi

matlab - 在 MATLAB 中如何生成随机数单元格?

转载 作者:行者123 更新时间:2023-12-02 01:02:39 26 4
gpt4 key购买 nike

假设我想生成 3 个大小为 3x4 的矩阵,每个矩阵都有随机条目 rand(3, 4)。如何将它们放入单元格 1x3

使用循环,很容易:

A = cell(1, 3);
for i=1:3
A{i}=rand(3, 4);
end

最佳答案

您可以将其存储在 3 维数组中:

A = rand(3,4,3);

访问第i层:

A(:,:,i)

关于matlab - 在 MATLAB 中如何生成随机数单元格?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24376303/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com