Thread Subject: constructing a 3D array (using permute?)

Subject: constructing a 3D array (using permute?)

From: Dave Brackett

Date: 22 Jul, 2008 17:45:06

Message: 1 of 2

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.

Subject: constructing a 3D array (using permute?)

From: Roger Stafford

Date: 22 Jul, 2008 19:04:03

Message: 2 of 2

"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

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
3d array Dave Brackett 22 Jul, 2008 13:50:20
permute Dave Brackett 22 Jul, 2008 13:50:19
rssFeed for this Thread
 

MATLAB Central Terms of Use

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.

Contact us at files@mathworks.com