Effacer les filtres
Effacer les filtres

how to get random pair ?

3 vues (au cours des 30 derniers jours)
marie lasz
marie lasz le 23 Fév 2021
Modifié(e) : the cyclist le 23 Fév 2021
Hello beautiful people,
Can anyone tell me that how I get random pair out of the following pairs?
I have these six pairs (1,5) (2,5) (3,3) (2,4) (2,5) (4,2)
these pairs represents x, y values/dimensiuons so I need one random pair like (2,5)....

Réponses (1)

the cyclist
the cyclist le 23 Fév 2021
Modifié(e) : the cyclist le 23 Fév 2021
How are these pairs currently stored?
This seems equivalent to just choosing a random number from 1-6, so you could do
idx = randi(6)
and choose the corresponding pair.
  12 commentaires
the cyclist
the cyclist le 23 Fév 2021
Modifié(e) : the cyclist le 23 Fév 2021
M = [1,5;
2,5;
3,3;
2,4;
2,5;
4,2;];
xy_random = M(randi(6),:);
str_input = sprintf("(%d,%d)",xy_random)
str_input = "(2,5)"
Walter Roberson
Walter Roberson le 23 Fév 2021
a = b(idx(1), idx(2)) + c

Connectez-vous pour commenter.

Catégories

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

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by