フィルターのクリア

Fast sampling every other element in a matrix

1 回表示 (過去 30 日間)
Christopher
Christopher 2014 年 10 月 2 日
コメント済み: Stephen23 2019 年 2 月 15 日
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);
  3 件のコメント
Orongo
Orongo 2019 年 2 月 15 日
what does the parameter 'end' mean here?
Stephen23
Stephen23 2019 年 2 月 15 日
@Orongo: "The end function also serves as the last index in an indexing expression"

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by