Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

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


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

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

Advanced Search

Back to Topic List Back to Topic List  
Jordan

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:
[A,A;
A,A]

The second layer (:,:,2) to look like this:
[B,B;
B,B]

The third layer (:,:,3) to look like this:
[C,C;
C,C]

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]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.