Fast sampling every other element in a matrix

2 次查看(过去 30 天)
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.

采纳的回答

Andrei Bobrov
Andrei Bobrov 2014-10-2
M2 = M(1:2:end,1:2:end);

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by