Line | |
---|
1 | function i = finddiag(A,k)
|
---|
2 | %FINDDIAG Index elements on the diagonal.
|
---|
3 | % FINDDIAG(A) returns the indices of the diagonal of A.
|
---|
4 | % FINDDIAG(A,K) returns the indices of the K-th diagonal of A.
|
---|
5 | %
|
---|
6 | % See also DIAG, SETDIAG.
|
---|
7 |
|
---|
8 | % Written by Tom Minka
|
---|
9 | % (c) Microsoft Corporation. All rights reserved.
|
---|
10 |
|
---|
11 | if nargin < 2
|
---|
12 | k = 0;
|
---|
13 | end
|
---|
14 | n = length(A);
|
---|
15 | if k >= 0
|
---|
16 | i = (k*n+1):(n+1):(n^2);
|
---|
17 | else
|
---|
18 | i = (1-k):(n+1):(n*(n+k));
|
---|
19 | end
|
---|
Note: See
TracBrowser
for help on using the repository browser.