help-octave
[Top][All Lists]
Advanced

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

Re: matrix transformation


From: James Sherman Jr.
Subject: Re: matrix transformation
Date: Wed, 27 May 2009 13:45:57 -0400

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.

On Wed, May 27, 2009 at 1:33 PM, John B. Thoo <address@hidden> wrote:

On May 27, 2009, at 9:40 AM, Paul Campbell wrote:


> On Wed, May 27, 2009 at 3:52 AM, Bertrand Roessli
> <address@hidden> wrote:
>> Hello,
>>
>> I would like to transform a matrix like
>> e.g.
>>
>>  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
>>
>> in
>>
>>  1 2 3
>>  4 5 6
>>  7 8 9
>>  1 2 3
>>  4 5 6
>>  7 8 9
>>  1 2 3
>>  4 5 6
>>  7 8 9
>>
>> Is there a simple way to do that?
>>
>> Thanks in advance
>>
>> Bertrand Roessli
>
> Found a simpler method
>
> A'
>
> http://wiki.aims.ac.za/mediawiki/index.php/Octave:Vectors_and_matrices

Hi.  I don't know how to accomplish Bertrand's request easily;
however, I don't think A'  does it.

octave-3.0.5:32> M = [1, 2, 3; 4, 5, 6; 7, 8, 9];
octave-3.0.5:33> A = [M, M, M];  % Bertrand's original
octave-3.0.5:34> B = [M; M; M];  % what Bertrand wants
octave-3.0.5:35> B - A'
ans =

   0  -2  -4
   2   0  -2
   4   2   0
   0  -2  -4
   2   0  -2
   4   2   0
   0  -2  -4
   2   0  -2
   4   2   0

octave-3.0.5:36>

---John.
_______________________________________________
Help-octave mailing list
address@hidden
https://www-old.cae.wisc.edu/mailman/listinfo/help-octave


reply via email to

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