代写代考 function T = tridiagExample(N,nonsym)

function T = tridiagExample(N,nonsym)
% set up the tridiagonal matrix for hw6
% when nonsym = 0, this is the matrix shown on AG p.95, but without the 1/h^2 factors
% when nonsym is not 0, this is a matrix related to that discussed in

Copyright By PowCoder代写 加微信 powcoder

% AG, p.304, but without the 1/(2h) factors
T = sparse(N);
T(1,1) = 2;
T(1,2) = -1 – nonsym;
for k=2:N-1
T(k,k-1) = -1 + nonsym;
T(k,k) = 2;
T(k,k+1) = -1 – nonsym;
T(N,N-1) = -1 + nonsym;
T(N,N) = 2;

程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com