1 function A = tridiagonal(integerN, x, y, z)
3 % Construct the integerN x integerN (square) tridiagonal matrix
8 % - ``integerN`` -- The dimensions of the resulting matrix.
10 % - ``x`` -- The value on the subdiagonal.
12 % - ``y`` -- The value on the diagonal.
14 % - ``z`` -- The value on the superdiagonal.
21 sub_diag = repmat(x, 1, integerN-1);
22 on_diag = repmat(y, 1, integerN);
23 super_diag = repmat(z, 1, integerN-1);
24 A = diag(on_diag) + diag(super_diag, 1) + diag(sub_diag, -1);