Splitting an array and working on individual sections.

1 回表示 (過去 30 日間)
Bob Whiley
Bob Whiley 2015 年 4 月 9 日
回答済み: David Young 2015 年 4 月 9 日
I have a large MxN array, M and N are both even, how can i split the array into 2x2 smaller arrays and perform operations on each separately?

回答 (1 件)

David Young
David Young 2015 年 4 月 9 日
If you want to put the four smaller arrays into separate variables, you can do it like this (assuming the sizes are even as stated):
topLeft = A(1:end/2, 1:end/2);
topRight = A(1:end/2, end/2+1:end);
bottomLeft = A(end/2+1:end, 1:end/2);
bottomRight = A(end/2+1:end, end/2+1:end);
Then process each small array in any way you like.
But perhaps you want to do this in a loop, processing each quadrant in turn? If so, you can probably work out what to do from the code above, but it it's still a problem please say.

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by