Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
random number

Subject: random number

From: george veropoulos

Date: 17 Mar, 2012 13:18:11

Message: 1 of 3

Hi my friends
i would to ask you if there a method (or function)
to produce a random series of nimber around a specifiec number

for example 3.4 , 3.5,3.7, 3.8, etc

thank you in advance
george

Subject: random number

From: Nasser M. Abbasi

Date: 17 Mar, 2012 14:31:46

Message: 2 of 3

On 3/17/2012 8:18 AM, george veropoulos wrote:
> Hi my friends
> i would to ask you if there a method (or function)
> to produce a random series of nimber around a specifiec number
>
> for example 3.4 , 3.5,3.7, 3.8, etc
>
> thank you in advance
> george

may be

EDU>> std=.1;
EDU>> mean=3.5;
EDU>> mean + std.*randn(6,1)

ans =

     3.5722
     3.7585
     3.4333
     3.5187
     3.4918
     3.3067


--Nasser

Subject: random number

From: ImageAnalyst

Date: 17 Mar, 2012 15:59:23

Message: 3 of 3

Or you can have them uniformly distributed like

% Set up parameters:
center = 3;
range = 2;
numberOfNumbers = 100;

% Now get the array.
numbers = center + range * rand(1, numberOfNumbers) - range/2

% Let's check where they fall to see if we did it correctly:
minValue = min(numbers)
maxValue = max(numbers)

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us