random number within a rwo vector

1 view (last 30 days)
Raviteja
Raviteja on 17 Sep 2011
I have a row vector say
>> A
A =[ -29 -17 -11 -10 -8 -8 -7 -2 -1 3 3 3 8 13 14]
I want to randomly generate a number within this A only.
How to do this?

Accepted Answer

James Tursa
James Tursa on 17 Sep 2011
A(ceil(rand*numel(A)))
  2 Comments
Andrei Bobrov
Andrei Bobrov on 17 Sep 2011
A1 = unique(A)
out = A1(randi(numel(A1)))

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!