使用smithForm函数
示例
% simplify函数用于化简表达式
>> syms x
>> y = x^2+2*x+1;
>> simplify(y)
%{
ans =
(x + 1)^2
%}
% 矩阵A
>> A=[x+1 2 -6;1 x -3;1 1 x-4]
%{
A =
[x + 1, 2, -6]
[ 1, x, -3]
[ 1, 1, x - 4]
%}
% 求矩阵A的Smith标准形
>> simplify(smithForm(A))
%{
ans =
[1, 0, 0]
[0, x - 1, 0]
[0, 0, (x - 1)^2]
%}