Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: constructing a 3D array (using permute?)
Date: Tue, 22 Jul 2008 19:04:03 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 29
Message-ID: <g65av3$mno$1@fred.mathworks.com>
References: <g656b2$4o1$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1216753443 23288 172.30.248.38 (22 Jul 2008 19:04:03 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 22 Jul 2008 19:04:03 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: news.mathworks.com comp.soft-sys.matlab:481063



"Dave Brackett" <davebrackett@hotmail.com> wrote in message <g656b2
$4o1$1@fred.mathworks.com>...
> I have some code as follows:
> 
>  a=rand(50,16)
>  b=pi*a.^2
> 
>  f=1:100
>  w=2*pi*f
> 
>  c=sqrt((w'.*b)/(pi))
> 
> 
> This returns an error stating that the matrix dimensions
> must agree as would be expected because w' is [100 1] and b
> is [50 16].
> 
> My question is, how can I assemble a 3D array of size [100
> 16 50] to be stored as c, from w' and b? 
> 
> I think permute is needed but can't get it to do what I want.
> Hopefully you can help. Thanks.

  I believe you need to first use 'shiftdim' by -1 with b, producing a three-
dimensional array with a first dimension singleton.  Then apply 'bsxfun' with 
"@times" using this and w/pi.

Roger Stafford