필터 지우기
필터 지우기

creating matrix of 1 nd -1

조회 수: 2 (최근 30일)
umar siyab
umar siyab 2012년 3월 21일
how can i generate random matrix of 1 and -1 ...
thanks in advance
  댓글 수: 2
Thomas
Thomas 2012년 3월 21일
Do you want the elements of the matrix to be only 1 and -1 or between 1 and -1
umar siyab
umar siyab 2012년 3월 21일
i want my matrix to be 1 and -1 and it should be 256 by 256 ... basically i want a pesudo random bit generator which can generate a matrix of 1 and -1

댓글을 달려면 로그인하십시오.

답변 (2개)

Jan
Jan 2012년 3월 21일
1 and -1:
x = 1 - (rand(3,5) > 0.5) *2;
From -1 to 1:
x = 1 - rand(3,5) *2;
  댓글 수: 1
umar siyab
umar siyab 2012년 3월 21일
thanks sir
and it really helped me..

댓글을 달려면 로그인하십시오.


David Young
David Young 2012년 3월 21일
Assuming that you want values of 1 and -1 only, you can do
2*randi(2, m, n) - 3
  댓글 수: 1
umar siyab
umar siyab 2012년 3월 21일
sorry it is undefined function in matlab i think ....m new to matlab so don'y know much about these fnction

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by