Splitting a table to 2
Afficher commentaires plus anciens
Hello all, I have a table named A. I want to split it into 2 sub-tables: Table 1 has 60% of the rows in A, chosen randomly. Table 2 has all the other rows that are not in table 1. Any elegant idea on how to do this?
Réponse acceptée
Plus de réponses (2)
Note that this will only play nicely if you have a reasonably large array.
selection = randi([1 10], size(A,1),1)
A_sixty = A(selection>4);
A_forty = A(selection<=4);
Sean de Wolski
le 16 Août 2017
0 votes
If you're looking to split your data into a training and testing set, then it might pay to look at cvpartition as well, it provides more options for splitting tables.
Catégories
En savoir plus sur Tables dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!