The Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.matlab

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Replicating an array into a 3D layered matrix - Help please!
Replies: 0  

Advanced Search

Back to Topic List Back to Topic List  

Posts: 4
Registered: 1/22/12
Replicating an array into a 3D layered matrix - Help please!
Posted: Jan 14, 2013 4:34 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Hi all. I'm struggling with some coding and can't seem to figure it out. I'd prefer to do this without for-loops.

I have a vector of length N. For now, let's say it's length 3: [A,B,C]'

I want to replicate this into a layered matrix size (2,2,N), so for this case (2,2,3).

I want the first layer (:,:,1) to look like this:

The second layer (:,:,2) to look like this:

The third layer (:,:,3) to look like this:

And so on, through N.

So basically I want to take a vector of N ingredients and make a cake with N tiers, each tier being 2x2 and consisting of only one corresponding ingredient from (1:N). Hope that makes sense.

Any suggestions? I'm sure this can probably be done through repmat() somehow, but I can't figure it out. Thanks in advance!

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.