Rev | Line | |
---|
[37] | 1 | function A = setdiag(A,v,k)
|
---|
| 2 | %SETDIAG Modify the diagonal(s) of a matrix.
|
---|
| 3 | % SETDIAG(A,V) returns a copy of A where the main diagonal is set to V.
|
---|
| 4 | % V can be a scalar or vector.
|
---|
| 5 | % SETDIAG(A,V,K) sets the K-th diagonal to V. The K-th diagonal has length
|
---|
| 6 | % N-ABS(K).
|
---|
| 7 | %
|
---|
| 8 | % See also DIAG, FINDDIAG.
|
---|
| 9 |
|
---|
| 10 | % Written by Tom Minka
|
---|
| 11 | % (c) Microsoft Corporation. All rights reserved.
|
---|
| 12 |
|
---|
| 13 | if nargin < 3
|
---|
| 14 | k = 0;
|
---|
| 15 | end
|
---|
| 16 | A(finddiag(A,k)) = v;
|
---|
Note: See
TracBrowser
for help on using the repository browser.