[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Help with matrix replication
From: |
Bård Skaflestad |
Subject: |
Re: Help with matrix replication |
Date: |
Thu, 20 Dec 2012 18:08:50 +0100 |
On Thu, 2012-12-20 at 16:50 +0000, Richardson, Anthony wrote:
> I want to duplicate the rows in a matrix n times and then duplicate
> the columns n times.
Here is one simple way,
ix = @(sz, n) cumsum (mod (1 : n*sz, n) == 1);
a = [ 1, 2, 3 ; 4, 5, 6 ];
n = 2;
i = ix (size (a, 1), n);
j = ix (size (a, 2), n);
b = a (i, j);
It uses quite a bit of memory, though.
Sincerely,
--
Bård Skaflestad <address@hidden>