hello! how can I create a matrix (size 10X10) with random numbers of 1 and -1?

1 次查看(过去 30 天)
hello! how can I create a matrix (size 10X10) with random numbers of 1 and -1?

回答(1 个)

Dyuman Joshi
Dyuman Joshi 2022-5-15
y=[-1 1];
z=y(randi(2,10,10))
z = 10×10
-1 -1 -1 1 -1 1 -1 -1 1 1 -1 -1 -1 1 -1 1 1 1 -1 -1 1 -1 -1 -1 -1 1 1 -1 -1 -1 -1 -1 -1 1 1 -1 -1 -1 -1 1 -1 -1 1 -1 1 1 -1 1 1 1 1 1 1 -1 1 -1 -1 1 -1 -1 -1 1 -1 1 -1 -1 1 1 1 1 -1 -1 -1 1 1 -1 1 -1 1 -1 1 1 -1 -1 1 -1 -1 -1 1 1 -1 1 1 1 -1 1 -1 -1 1 -1

类别

Help CenterFile Exchange 中查找有关 Random Number Generation 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by