"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.
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for
all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content.
Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available
via MATLAB Central.
Read the complete Terms prior to use.