Fast sampling every other element in a matrix
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Christopher
am 2 Okt. 2014
Kommentiert: Stephen23
am 15 Feb. 2019
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 Kommentare
Akzeptierte Antwort
Andrei Bobrov
am 2 Okt. 2014
M2 = M(1:2:end,1:2:end);
3 Kommentare
Stephen23
am 15 Feb. 2019
@Orongo: "The end function also serves as the last index in an indexing expression"
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!