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: vector/matrix manipulation question
Replies: 3   Last Post: Feb 14, 2013 6:37 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
P

Posts: 26
Registered: 8/4/08
vector/matrix manipulation question
Posted: Feb 14, 2013 3:07 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Hello,

I'm trying to figure out the simplest Matlab syntax to deal the following 2 scenarios:

1. let a = [1 2 3; 4 5 6]

what's the cleanest syntax to duplicate each row of a by a factor of x? Let say x = 2, I want to final outcome looking like

b = [1 2 3; 1 2 3; 4 5 6; 4 5 6]

if I use repmat(a, 1, 2), I get
b = [1 2 3; 4 5 6; 1 2 3; 4 5 6]

This is not really what I wanted


2. Is it possible to transpose an inner dimension of a multi-dimension matrx? Let say

[2 3 4] = size(a)

I want to transpose the latter 2 dimension of a such that

[2 4 3] = size(b)

Is there a simple command that can do these?

For both problems, I ended up writing for loop to perform the desired matrix transform. I'm curious if I miss a simpler solution somewhere


Thanks!



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.