Got Questions? Get Answers.
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 numbers and arrays

Subject: Random numbers and arrays

From: Ulrik Nash

Date: 13 Dec, 2009 16:07:04

Message: 1 of 3

How do I generate an array of n random numbers between a and b?

Subject: Random numbers and arrays

From: Ulrik Nash

Date: 13 Dec, 2009 16:14:05

Message: 2 of 3

UPDATE:

How do I generate an array of n random WHOLE numbers between a and b?

Subject: Random numbers and arrays

From: Matt Fig

Date: 13 Dec, 2009 17:40:33

Message: 3 of 3

There are several ways to do this.

a = 4;
b = 11;
c = floor(rand(1000000,1)*(b-a+1)+a);

% Now check
unique(c)
hist(c)

Tags for 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