How can I delete multiple elements from an array?

Hi all,
Say I have an array that's really large, say, 1000 x 1000, and I want to look only at the 10th element of each row, and the 10th element of each column, which would produce a 100 x 100 array. How can I do this?
Cheers, Henry

 採用された回答

Star Strider
Star Strider 2015 年 5 月 26 日

0 投票

This works:
A10 = A([1 10:10:end], [1 10:10:end]);
with ‘A’ being your (1000x1000) array.

4 件のコメント

Henry Kricancic
Henry Kricancic 2015 年 5 月 26 日
Nice, that works well enough - thank you.
What if I wanted to replace everything other than the 10th element of each row and column, with a zero? Which I would also like to do...
Star Strider
Star Strider 2015 年 5 月 26 日
My pleasure.
If I understand correctly what you want, this works:
A10 = A([1 10:10:end], [1 10:10:end])
A0 = zeros(size(A));
A0([1 10:10:end], [1 10:10:end]) = A10;
Henry Kricancic
Henry Kricancic 2015 年 5 月 26 日

Wow, you bloody beauty mate - thank you! Exactly what I needed :)

Star Strider
Star Strider 2015 年 5 月 27 日
My pleasure!

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

その他の回答 (0 件)

カテゴリ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by