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: expanding matrix while copying elements
Replies: 2   Last Post: Mar 19, 2013 3:59 PM

Advanced Search

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

Posts: 232
Registered: 12/7/04
Re: expanding matrix while copying elements
Posted: Mar 19, 2013 12:16 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

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




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.