[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: matrix transformation
From: |
Bertrand Roessli |
Subject: |
Re: matrix transformation |
Date: |
Thu, 28 May 2009 08:28:57 +0200 |
"reshape (permute (reshape (x, nr, nc, nb), [1, 3, 2]), nb*nr, nc)"
Amazing...
Thanks,
Bertrand
On Wed, 2009-05-27 at 13:54 -0400, John W. Eaton wrote:
> On 27-May-2009, James Sherman Jr. wrote:
>
> | I thought that Paul meant that you could use A' instead of permute in
> | Jaroslav's suggestion. Obviously, A' doesn't work by itself.
> |
> | I've played around a bit with just reshape and permute, but I can't seem to
> | think of an elegant solution or any solution at all that uses just reshape
> | and permute. The best solution that I can think of (assuming that the
> | initial matrix is always of the form [M,M, ..., M]) is just extracting M and
> | using rep mat, something like if M is an nxm matrix, and your initial matrix
> | is A:
> |
> | M = A(1:n,1:m);
> | B = repmat(A, k, 1);
> |
> | where k is the number of repetitions of M.
>
> x = [ 1 2 3 1 2 3 1 2 3
> 4 5 6 4 5 6 4 5 6
> 7 8 9 7 8 9 7 8 9 ]
> nr = rows (x)
> nc = 3
> nb = columns (x) / nc
> reshape (permute (reshape (x, nr, nc, nb), [1, 3, 2]), nb*nr, nc)
>
> jwe
> _______________________________________________
> Help-octave mailing list
> address@hidden
> https://www-old.cae.wisc.edu/mailman/listinfo/help-octave