www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/CompanionMatrixForPolynomialExample.m

    %% Companion Matrix for Polynomial
% Compute the companion matrix corresponding to the polynomial $(x-1)(x-2)(x+3) = x^3-7x+6$.
u = [1 0 -7 6];
A = compan(u)

%%
% The eigenvalues of |A| are the polynomial roots.
eig(A)