Hi I need a 1 line code for a random number generator between 1 and -1 for one element.

 채택된 답변

Wayne King
Wayne King 2012년 4월 15일

3 개 추천

Do you want these uniform between -1 and 1?
r = -1 + 2.*rand(100,1);
For 1 such number
r = -1+2*rand(1,1);

댓글 수: 1

Jan
Jan 2012년 4월 15일
@Mate 2u: If you read the help text of RAND you find corresponding examples. Please take the time to read the help and doc.

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

추가 답변 (0개)

카테고리

도움말 센터 및 File Exchange에서 Random Number Generation에 대해 자세히 알아보기

태그

질문:

2012년 4월 15일

Community Treasure Hunt

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

Start Hunting!

Translated by