Path: news.mathworks.com!not-for-mail
From: "John D'Errico" <woodchips@rochester.rr.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: vectorise a reshape loop
Date: Wed, 16 Jul 2008 13:37:02 +0000 (UTC)
Organization: John D'Errico (1-3LEW5R)
Lines: 38
Message-ID: <g5kthu$svb$1@fred.mathworks.com>
References: <g5krk2$77v$1@fred.mathworks.com>
Reply-To: "John D'Errico" <woodchips@rochester.rr.com>
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 1216215422 29675 172.30.248.35 (16 Jul 2008 13:37:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 16 Jul 2008 13:37:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 869215
Xref: news.mathworks.com comp.soft-sys.matlab:479742



"Dave Brackett" <davebrackett@hotmail.com> wrote in message 
<g5krk2$77v$1@fred.mathworks.com>...
> 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.

Try that again? What is the shape of M?
Is it 3x2x2x16? This is inconsistent with
what you have shown below.


> 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

Um, that is a 16x3 matrix.

Anyway, what loop?

Since you overwrite M on each pass
through, that non-loop does nothing
but define M at the last value of p.

We can't help you unless you will think
clearly enough about what you want to
explain it.

You might start by preallocating M to be
the proper size. Use zeros.

John