Determining Smith Form of a rectangular matrix
24 次查看(过去 30 天)
显示 更早的评论
I need to find Smith Form of a rectangular 3x2 matrix in MATLAB. I searched for documentation but all the solutions it has are for square matrices. Can anyone please help me in determining how I can find the Smith Form using smithForm for a rectangular matrix?
0 个评论
采纳的回答
Rohit Kulkarni
2022-7-5
Hi,
Open the Functions tab, which is besides the overview tab, it contains the function to evaluate smith form.
I don't think there is any way to use "smithForm" to find the smith form of non-square matrices and one will have to write an algorithm to compute it.
3 个评论
Rohit Kulkarni
2022-7-7
Hey, I tried some examples myself, I think its working right
A = [40 -20 36 12; -24 -4 28 48; 0 4 0 -8; 8 0 0 -8]
MNsmithForm(A)
B = [1 1; -2 6; 0 8]
MNsmithForm(B)
C = [6 -6 4; -6 -12 -8]
MNsmithForm(C)
Function in the link provided in the answer above:
function [SA, invFact, D] = MNsmithForm(A)
row = size(A,1);
col = size(A,2);
n = min(row,col);
minors = cell(1,n);
D0 = 1;
D0 = sym(D0);
D = sym(NaN(1,n));
invFact = sym(NaN(1,n));
for i = 1:n;
rowindex = false(1,row);
rowindex(1:i) = true;
rowperms = unique(perms(rowindex),'rows');
colindex = false(1,col);
colindex(1:i) = true;
colperms = unique(perms(colindex),'rows');
rownum = size(rowperms,1);
colnum = size(colperms,1);
minors{i} = sym(NaN(rownum,colnum));
for j=1:rownum;
for k=1:colnum;
Atmp = A;
Atmp = Atmp(rowperms(j,:),:);
Atmp = Atmp(:,colperms(k,:));
minors{i}(j,k) = det(Atmp);
end
end
rowlen = rownum*colnum; %(row - (i-1))*(col - (i-1));
minors{i} = reshape(minors{i},1,rowlen);
minors{i}(minors{i} == 0) = [];
D(i) = gcd(minors{i});
if i == 1
invFact(i) = D(i)/D0;
else
invFact(i) = D(i)/D(i-1);
end
end
SA = diag(invFact);
if row>col
zerorows = zeros(row-col,col);
SA = [SA;zerorows];
elseif col>row
zerocols = zeros(row,col-row);
SA = [SA, zerocols];
end
end
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Visualization and Data Export 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!