spdiag

PURPOSE ^

SPDIAG Sparse diagonal matrices and diagonals of a matrix.

SYNOPSIS ^

function S = spdiag(V,K)

DESCRIPTION ^

SPDIAG Sparse diagonal matrices and diagonals of a matrix.

 This is a sparse version of matlab's diag command, see the
 help of that command for its use.

 See also: DIAG, SPDIAGS

 (C) 2013 Andy Adler. License GPL v2 or v3

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function S = spdiag(V,K)
0002 %SPDIAG Sparse diagonal matrices and diagonals of a matrix.
0003 %
0004 % This is a sparse version of matlab's diag command, see the
0005 % help of that command for its use.
0006 %
0007 % See also: DIAG, SPDIAGS
0008 %
0009 % (C) 2013 Andy Adler. License GPL v2 or v3
0010 
0011 % Matlab's spdiags is really annoying. This function provides
0012 %  an interface like G-d intended
0013 
0014 if nargin == 1; K=0; end
0015 
0016 N = length(V) + K;
0017 V = [zeros(K,1);V(:)];
0018 S = spdiags(V(:), K, N, N);
0019 
0020 
0021 
0022 
0023 
0024 
0025 
0026

Generated on Wed 21-Jun-2017 09:29:07 by m2html © 2005