Fast sampling every other element in a matrix
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have a matrix M. I want to delete every other column and every other row. However, I already know how to do this as:
M = rand(100,11);
M2=M;
M2(:,2:2:end)=[];
M2(2:2:end,:)=[];
I will have to do this operation on large matrices many times in a loop, thus I am wondering if matlab has a built-in function to do this faster. Thanks.
0 commentaires
Réponse acceptée
Andrei Bobrov
le 2 Oct 2014
M2 = M(1:2:end,1:2:end);
3 commentaires
Stephen23
le 15 Fév 2019
@Orongo: "The end function also serves as the last index in an indexing expression"
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Matrix Indexing dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!