Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.
|
|
P
Posts:
26
Registered:
8/4/08
|
|
vector/matrix manipulation question
Posted:
Feb 14, 2013 3:07 PM
|
|
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!
|
|
|
|