Re: Invert Matrix




"Sheng" <illusionX82@xxxxxxxxxxx> wrote in message
news:ef3fa00.-1@xxxxxxxxxxxxxxxxxxxxxxxxxx
Hi guys,

If I have a matrix say, A=magic(4)

It will give me an end result of,

16 2 3 13
5 11 10 8
9 7 6 12
4 14 15 1

How can i write invert this matrix so that column 4 will start first
and then three, two and the last column will end with column one.

TO give,

13 3 2 16
8 10 11 5
12 6 7 9
1 15 14 4

Thanks for your help.

When I saw the subject, I was prepared to give my standard "Don't invert,
use backslash" warning, but I see you mean something different when you say
invert. As Dan said, you can do this type of manipulation with FLIPLR or
FLIPUD, but you can also use FLIPDIM or simple indexing:

A = magic(4);
B = A(:, end:-1:1)

In this context, end returns the number of columns in A, and end:-1:1 counts
backwards from that number to 1 by steps of -1. When you use that as the
index for the columns of A, the last column becomes first in the result, the
next-to-last becomes second, etc.

--
Steve Lord
slord@xxxxxxxxxxxxx


.



Relevant Pages

  • Re: FAT/dosfsck oddity
    ... does anyone notice something odd here? ... if you flip 2 backwards: ... then invert it: ...
    (comp.os.linux)
  • Re: pinv
    ... either -- it's intended for numeric matrices, ... equations, DON'T, repeat DO NOT INVERT IT. ... Instead use backslash to ... Steve Lord ...
    (comp.soft-sys.matlab)
  • Re: pinv
    ... You can't invert this matrix; rows 1 and 3 are identical, ... either -- it's intended for numeric matrices, ... Steve Lord ...
    (comp.soft-sys.matlab)