help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: matrix transformation


From: John W. Eaton
Subject: Re: matrix transformation
Date: Wed, 27 May 2009 13:54:24 -0400

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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]