Filter löschen
Filter löschen

random number within a rwo vector

1 Ansicht (letzte 30 Tage)
Raviteja
Raviteja am 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?

Akzeptierte Antwort

James Tursa
James Tursa am 17 Sep. 2011
A(ceil(rand*numel(A)))
  2 Kommentare
Raviteja
Raviteja am 17 Sep. 2011
A(fix(1 + (length(A))*rand(1)))
also working
Andrei Bobrov
Andrei Bobrov am 17 Sep. 2011
A1 = unique(A)
out = A1(randi(numel(A1)))

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Random Number Generation finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by