Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: vectorise a reshape loop
Date: Wed, 16 Jul 2008 13:04:02 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 27
Message-ID: <g5krk2$77v$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 1216213442 7423 172.30.248.35 (16 Jul 2008 13:04:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 16 Jul 2008 13:04:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1338633
Xref: news.mathworks.com comp.soft-sys.matlab:479734



Hi, I am having trouble vectorising the below for loop. Can
anyone help me please? I am expecting M to consist of 3 rows
of 2x2 matrices each with 16 deep. Thanks in advance.

for p=1:3
q=p;
M=reshape([a(:,q) c(:,q) b(:,q) d(:,q)].', 2, 2, []);
end

where a,b,c,d are 3x16 matrice such as: 
(imaginary parts can be ignored)
   1.0000 + 0.0000i   0.9999 + 0.0000i   0.9999 + 0.0001i
   1.0000 + 0.0000i   0.9999 + 0.0000i   0.9999 + 0.0001i
   1.0000 + 0.0000i   0.9999 + 0.0000i   0.9999 + 0.0001i
   1.0000 + 0.0000i   0.9999 + 0.0000i   0.9999 + 0.0001i
   1.0004 + 0.0000i   1.0003 + 0.0000i   1.0002 + 0.0001i
   1.0004 + 0.0000i   1.0003 + 0.0000i   1.0002 + 0.0001i
   1.0003 + 0.0000i   1.0003 + 0.0000i   1.0002 + 0.0001i
   1.0003 + 0.0000i   1.0003 + 0.0000i   1.0002 + 0.0001i
   1.0051 + 0.0000i   1.0050 + 0.0000i   1.0050 + 0.0001i
   1.0068 + 0.0000i   1.0068 + 0.0000i   1.0067 + 0.0001i
   1.0111 + 0.0000i   1.0110 + 0.0000i   1.0110 + 0.0001i
   1.0178 + 0.0000i   1.0178 + 0.0000i   1.0177 + 0.0001i
   1.0500 + 0.0000i   1.0499 + 0.0000i   1.0498 + 0.0000i
   1.1666 + 0.0000i   1.1666 + 0.0000i   1.1665 + 0.0000i
   1.2666 + 0.0000i   1.2666 + 0.0000i   1.2665 + 0.0000i
   3.2499 + 0.0000i   3.2497 + 0.0000i   3.2493 + 0.0000i