No BSD License  

Highlights from
ChebyshevTools

from ChebyshevTools by Michael Watson
Tool box for solving ODE/PDEs using spectral Chebyshev differentiation matrices.

v=getdiag(A,n);
function v=getdiag(A,n);

%extract the nth diag from matrix A
% n = 0 main diag

absn=abs(n);

M=max(size(A));

v=zeros(M-absn,1);


if (n>=0)
   for j=1:M-absn
      v(j,1)=A(j,j+n);     
   end
else
    for j=absn+1:M
      v(j-absn,1)=A(j,j+n);     
   end
end

Contact us at files@mathworks.com