代码如下:
%==========================================
n = 10;%随便指定n的值
syms x;
T = repmat(1:n,n,1);
T = T - diag([1:n]);
D = 1;
for i = 2:n
D = [D,x+1];
end
A = T + diag(D);
det(A)
%==========================================
结果:
ans =
(x - 2)*(x - 3)*(x - 4)*(x - 5)*(x - 6)*(x - 7)*(x - 8)*(x^2 - 10*x + 9)