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?

 採用された回答

James Tursa
James Tursa 2011 年 9 月 17 日

0 投票

A(ceil(rand*numel(A)))

2 件のコメント

Raviteja
Raviteja 2011 年 9 月 17 日
A(fix(1 + (length(A))*rand(1)))
also working
Andrei Bobrov
Andrei Bobrov 2011 年 9 月 17 日
A1 = unique(A)
out = A1(randi(numel(A1)))

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange で Random Number Generation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by