Fast sampling every other element in a matrix

3 visualizaciones (últimos 30 días)
Christopher
Christopher el 2 de Oct. de 2014
Comentada: Stephen23 el 15 de Feb. de 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.

Respuesta aceptada

Andrei Bobrov
Andrei Bobrov el 2 de Oct. de 2014
M2 = M(1:2:end,1:2:end);
  3 comentarios
Orongo
Orongo el 15 de Feb. de 2019
what does the parameter 'end' mean here?
Stephen23
Stephen23 el 15 de Feb. de 2019
@Orongo: "The end function also serves as the last index in an indexing expression"

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.

Productos

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by