Determining Smith Form of a rectangular matrix
12 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Akshay Vivek Panchwagh
le 5 Juil 2022
Commenté : Akshay Vivek Panchwagh
le 7 Juil 2022
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 commentaires
Réponse acceptée
Rohit Kulkarni
le 5 Juil 2022
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 commentaires
Rohit Kulkarni
le 7 Juil 2022
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
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Visualization and Data Export dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!