Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Divide, operate and reassemble matrix
Date: Thu, 18 Jun 2009 21:23:01 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 32
Message-ID: <h1eb7l$531$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1245360181 5217 172.30.248.35 (18 Jun 2009 21:23:01 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 18 Jun 2009 21:23:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1875128
Xref: news.mathworks.com comp.soft-sys.matlab:548771


Hi
I have a problem with a large matrix, what I want to do is to divide the matrix into 4 submatrices, do some operation then reassemble the submatrix together. A toy example

A = [1 2 3 ; 3 4 5 ; 2 3 4; 5 1 2 ]
A =

     1 2 3
     3 4 5
     2 3 4
     5 1 2
 I want to divide A into ANY 4 approximately equal sized partitions, for example
1 2
3 4

3
5

2 3
5 1

4
2

then do some operation, say add 2 to each element. Then reassemble them together, to get

     3 4 5
     5 6 7
     4 5 6
     7 3 4
What is the most efficient way of doing this?
Thanks
Diego