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

12 views (last 30 days)
shaked peled
shaked peled on 15 May 2022
Commented: Dyuman Joshi on 15 May 2022
hello! how can I create a matrix (size 10X10) with random numbers of 1 and -1?

Answers (1)

Dyuman Joshi
Dyuman Joshi on 15 May 2022
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

Community Treasure Hunt

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

Start Hunting!

Translated by