フィルターのクリア

random number between -1 and 1

32 ビュー (過去 30 日間)
Mate 2u
Mate 2u 2012 年 4 月 15 日
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 日
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 件)

カテゴリ

Help Center および File ExchangeRandom Number Generation についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by