Clear Filters
Clear Filters

random number between -1 and 1

32 views (last 30 days)
Mate 2u
Mate 2u on 15 Apr 2012
Hi I need a 1 line code for a random number generator between 1 and -1 for one element.

Accepted Answer

Wayne King
Wayne King on 15 Apr 2012
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 Comment
Jan
Jan on 15 Apr 2012
@Mate 2u: If you read the help text of RAND you find corresponding examples. Please take the time to read the help and doc.

Sign in to comment.

More Answers (0)

Categories

Find more on Random Number Generation in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!