How can I randomly pick a row (A) from a matrix give the same value from array (B)?
Afficher commentaires plus anciens
I have a coordinate matrix (A) which is nx2, and an index array (B) which is nx1. for example:
A=[1,2; 0,3; 3,8; 6,5; ....; 3,7];
B=[1;2;2;3;1;1;3;...3; 2];
I want to randomly pick a row from A which has the same value group from B. for example:
G1=random a row [Ax1, Ay1; such that B=1];
G2=random a row [Ax2, Ay2; such that B=2];
G3=random a row [Ax3, Ay3; such that B=3]; and so on
G1,G2 ... are 1x2 corrdinate arrays.
Is there a command or simple algorithm to do the reandom assigmenet
1 commentaire
Zhi Yuan Liao
le 13 Mar 2019
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Mathematics dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!