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

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

카테고리

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