Determining Smith Form of a rectangular matrix

26 visualizaciones (últimos 30 días)
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?

Respuesta aceptada

Rohit Kulkarni
Rohit Kulkarni el 5 de Jul. de 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 comentarios
Rohit Kulkarni
Rohit Kulkarni el 7 de Jul. de 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]
A = 4×4
40 -20 36 12 -24 -4 28 48 0 4 0 -8 8 0 0 -8
MNsmithForm(A)
ans = 
B = [1 1; -2 6; 0 8]
B = 3×2
1 1 -2 6 0 8
MNsmithForm(B)
ans = 
C = [6 -6 4; -6 -12 -8]
C = 2×3
6 -6 4 -6 -12 -8
MNsmithForm(C)
ans = 
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
Akshay Vivek Panchwagh
Akshay Vivek Panchwagh el 7 de Jul. de 2022
Thanks a lot! This is working perfectly fine.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Visualization and Data Export en Help Center y File Exchange.

Productos


Versión

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by