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

1 vue (au cours des 30 derniers jours)
shaked peled
shaked peled le 15 Mai 2022
Commenté : shaked peled le 15 Mai 2022
hello! how can I create a matrix (size 10X10) with random numbers of 1 and -1?

Réponses (1)

Dyuman Joshi
Dyuman Joshi le 15 Mai 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

Catégories

En savoir plus sur Random Number Generation dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by