Search All of the Math Forum:

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

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

Topic: expanding matrix while copying elements
Replies: 2   Last Post: Mar 19, 2013 3:59 PM

 Messages: [ Previous | Next ]
 Bruce Bowler Posts: 303 Registered: 12/7/04
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
>
> 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

Date Subject Author
3/19/13 Bruce Bowler
3/19/13 Bruno Luong