Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
4.A. A note on Matlab 's function spdiags 101 4.A. A note on Matlab 's function spdiags Matlab provides a very convenient way to construct sparse diagonal matrices. This is achieved with the function spdiags . We briefly explain its usage. Consider the command D = spdiags(B,d,m,n) ; B is a matrix in which diagonals are stored column by column (all of same length). The argument d specifies the location of the diagonals. As an example, take 1 6 11 6 7 6 2 7 12 7 6 7 6 7 B 6 3 8 13 7 6 7 6 4 9 14 7 5 4 5 10 15 2 3 and £ / d ¡ 2 0 1 . Then, the diagonals are placed into a matrix at rows as indicated in vector d . The number of columns is defined by the number of rows in B . This is shown in the leftmost figure in the picture below.