Select only determined rows in a matrix
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Emilio Pulli
le 28 Nov 2021
Commenté : Emilio Pulli
le 28 Nov 2021
I have a matrix composed of 200 rows and I want to copy in another matrix one every 10 rows obtaining a final matrix of 20 rows...is there a smart way to do it or do I have to use a for loop to index the orws I want to copy?
0 commentaires
Réponse acceptée
the cyclist
le 28 Nov 2021
% First matrix
A = rand(200,2);
% New matrix
B = A(10:10:end,:); % This will start with the 10th row. You could do B = A(1:10:end,:) to start with the first row.
Plus de réponses (1)
DGM
le 28 Nov 2021
Something like this. You'll have to adjust the starting index as needed:
A = repmat((1:100).',[1 4]) % smaller example (100x4)
B = A(10:10:end,:)
Voir également
Catégories
En savoir plus sur Multidimensional Arrays 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!