Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.



Re: expanding matrix while copying elements
Posted:
Mar 19, 2013 12:16 PM


Perfect, thanks!
On Tue, 19 Mar 2013 11:59:30 0400, Josh Meyer wrote:
> You can use the kronecker tensor product function, 'kron', to do this. > It multiplies the second array by each element of the first array to > produce 'blocks', then constructs a large matrix out of those blocks. > > For example, > > X = [1 2 3;4 5 6]; > Y = kron(X,ones(2,2)) > > Y = > > 1 1 2 2 3 3 1 1 2 2 3 3 4 > 4 5 5 6 6 4 4 5 5 6 6 > > for more information, > http://www.mathworks.com/help/matlab/ref/kron.html > > Josh Meyer josh.meyer@mathworks.com "Bruce Bowler" > <bbowler@bigelow.org> wrote in message > news:aqrf7gF2hv4U1@mid.individual.net... >> Howdy. I know I can do this with a couple of loops, but that just >> feels wrong... >> >> I have a MxN matrix that I want to turn into a 12Mx12N matrix, filling >> in the intermediate elements. Here's a brief example  Suppose the >> initial matrix is 2x3 and I want to end up with 4x6 >> >> This 1 2 3 should end up as this 1 1 2 2 3 3 >> 4 5 6 1 1 2 2 3 3 >> 4 4 5 5 6 6 4 4 5 5 6 6 >> >> TIA, >> Bruce



