random number within a rwo vector

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에서 Quantum Mechanics에 대해 자세히 알아보기

질문:

2011년 9월 17일

Community Treasure Hunt

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

Start Hunting!

Translated by