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: Thu, 17 Jul 2008 13:59:03 +0000 (UTC)
Organization: John D'Errico (1-3LEW5R)
Lines: 50
Message-ID: <g5nj77$j6j$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> <g5ngf2$fdp$1@fred.mathworks.com>
Reply-To: "John D'Errico" <woodchips@rochester.rr.com>
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 1216303143 19667 172.30.248.37 (17 Jul 2008 13:59:03 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 17 Jul 2008 13:59:03 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 869215
Xref: news.mathworks.com comp.soft-sys.matlab:479981



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

Ah. This was the problem. Yes, I don't think
there is any real limit on the number of
dimensions. Yes, there may be a limit, but
it is probably some large number.

 
> 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:

Its not my ndfun.


> 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.

What would be the result of this product?
Perhaps just a 2x2 array? How do you
expect a 2x2 array to fit into a single
array element of prodH? Why would you
index the result as prodH(1,q) ?

If that result is a 2x2 array, and you have
preallocated prodH as 2x2x3, then should
you not do it as

   prodH(:,:,q)=ndfun('mprod',M(:,:,p,:));

John