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

조회 수: 11(최근 30일)
shaked peled
shaked peled 2022년 5월 15일
댓글: Dyuman Joshi 2022년 5월 15일
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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by