MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   资料存档 (https://www.labfans.com/bbs/forumdisplay.php?f=72)
-   -   Matlab-具有1s(或0s)高浓度的二进制向量 (https://www.labfans.com/bbs/showthread.php?t=23256)

poster 2019-12-10 20:30

Matlab-具有1s(或0s)高浓度的二进制向量
 
生成数量为N的,大小为N的随机二进制向量的数量为X的最佳方法是什么?浓度为1s(或者模拟为0s),范围从非常低到非常高?

使用randint或unidrnd(如[URL="https://stackoverflow.com/questions/2442141/uniform-distribution-of-binary-values-in-matlab"]本问题所示[/URL] )将生成具有均匀分布的二进制矢量,在这种情况下,这不是我所需要的。

任何帮助表示赞赏!



[B]回答:[/B]

[URL="https://stackoverflow.com/questions/2549339/matlab-binary-vector-with-high-concentration-of-1s-or-0s/2549370#2549370"]Laserallan[/URL]的方法是必经之路。

对于具有10个元素和70%随机分布的向量,您可以编写

randVec = rand(10,1)


所有时间均为北京时间。现在的时间是 13:40

Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.