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

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

Risposte (1)

Dyuman Joshi
Dyuman Joshi il 15 Mag 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

Categorie

Scopri di più su Random Number Generation in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by