Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: vectorise a reshape loop
Date: Thu, 17 Jul 2008 13:12:02 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 25
Message-ID: <g5ngf2$fdp$1@fred.mathworks.com>
References: <g5krk2$77v$1@fred.mathworks.com> <g5kthu$svb$1@fred.mathworks.com> <g5n4kd$jtp$1@fred.mathworks.com> <g5n9fu$6vv$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1216300322 15801 172.30.248.37 (17 Jul 2008 13:12:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 17 Jul 2008 13:12:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1338633
Xref: news.mathworks.com comp.soft-sys.matlab:479971



I think the communication issue stems from the fact i didn't
understand the number of array dimensions could be above 3.
To me, a matrix with rows, columns, and pages was always a
3D matrix (as it forms a 3D 'block'). Evidently this is not
the case.

The reshape and permute functions you suggest do achieve
what I wanted thanks:
M=reshape([ai_col(:),bi_col(:),ci_col(:),di_col(:)],16,3,2,2);
M=permute(M,[3 4 2 1]);

For each of the 3 sets of 16 2x2 arrays contained within M I
want to find the product in the dimension of the 16 2x2
matrices. I have been using your ndfun mex file as follows:

prodH=zeros(2,2,3);
for p=1:3
    q=p;
    prodH(1,q)=ndfun('mprod',M(:,:,p,:))
end

However, i get the error that 'assignment has more
non-singleton rhs dimensions than non-singleton subscripts'.
Could you show me how to do this correctly pls? Thanks for
your help.