function y = trid(A,B,C,N)
%creates an NxN tridiagonal matrix with
%A's below the main diagonal, B's on the main diagonal,
%and C's above the main diagonal.
y = diag(A*ones(N-1,1),-1)+ diag(B*ones(N,1),0)+ diag(C*ones(N-1,1),1);