help-octave
[Top][All Lists]

## Re: FW: Matrix index, Please e-mail back.

 From: Jordi Gutierrez Hermoso Subject: Re: FW: Matrix index, Please e-mail back. Date: Tue, 5 Dec 2006 17:00:55 -0600

```Argh... No offense, and I normally try to be tolerant about top-posters
and HTML emails, but this time I honestly have a hard time understand
who said what and what's going on with this email thread. Ever heard
of trim-posting? To be fair, not many people are even aware that a
different posting style exists:

http://en.wikipedia.org/wiki/Top-posting

Anyways, after a while of reading this thread, I think I understand
what's going on. More trim-posted below:

[huge snip]
| I want to index with [2,3,4] and then [3,4,5] ... [4,5,6] by letting
| i index the index range matrix. Can you do it with octave.
| My octave script works if in a loop. The loop is some slow
| so that is why I would like to use an index to the index ranges.
[more snipped]

I don't understand what you think the bug is, but jwe seemed

At any rate, it sounds you want to get the diagonal of a matrix plus
the super- and subdiagonal. This is easy to do:

octave:2> A = [1 2 3 4; 5 6 7 8; 9 10 11 12; 13 14 15 16]
A =

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

octave:3> diag(A)
ans =

1
6
11
16

octave:4> diag(A,1)
ans =

2
7
12

octave:5> diag(A,-1)
ans =

5
10
15