Effacer les filtres
Effacer les filtres

select random values from vector

1 vue (au cours des 30 derniers jours)
Hello Matlab
Hello Matlab le 4 Fév 2015
I have a vector:
[R1,R2]= Where R1 = 7 3 3 5 3
R2 = 5 5 5 4 6
I want to randomly select one of these pairs, like [7,5]. How I can do this in Matlab?

Réponses (2)

Azzi Abdelmalek
Azzi Abdelmalek le 4 Fév 2015
idx1=randi(numel(R1))
idx2=randi(numel(R2))
out=[R1(idx1) R2(idx2)]

Stalin Samuel
Stalin Samuel le 4 Fév 2015
c1 = randi([1 numel(R1)],1,1)
c2 = randi([1 numel(R2)],1,1)
result = [R1(c1) R2(c2)]
or
result = [R1(c1) R2(c1)]

Catégories

En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by