Fast sampling every other element in a matrix
1 次查看(过去 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.
0 个评论
采纳的回答
Andrei Bobrov
2014-10-2
M2 = M(1:2:end,1:2:end);
3 个评论
Stephen23
2019-2-15
@Orongo: "The end function also serves as the last index in an indexing expression"
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!