Re: Invert Matrix
- From: "Steven Lord" <slord@xxxxxxxxxxxxx>
- Date: Thu, 31 Aug 2006 09:21:07 -0400
"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
.
- References:
- Invert Matrix
- From: Sheng
- Invert Matrix
- Prev by Date: Re: PCA
- Next by Date: controling instruments through gpib
- Previous by thread: Re: Invert Matrix
- Next by thread: Catching an error
- Index(es):
Relevant Pages
|