Azzera filtri
Azzera filtri

issue using the rref function ?!

2 visualizzazioni (ultimi 30 giorni)
Ano
Ano il 31 Lug 2017
Commentato: Ano il 1 Ago 2017
Hello! I would like to use rref function in order to remove the linearly dependent elements from my matrix , but when using rref I get the number of basic columns as 1 which is not correct! any suggestion of any potential error in my code will be very welcomed ! thank you in advance !
load('matFile.mat', 'MyMatrix')
>> [rows, columns]=size(MyMatrix);
>> reshapedMatrix = reshape(MyMatrix,(rows * columns),1);
>> Gram = reshapedMatrix * reshapedMatrix';
>> GramDeterm = det(Gram);
>> if (GramDeterm <0.1)
[E,basiccol] = rref(Gram);
MatrixOut = Gram(:,basiccol)';
end
  2 Commenti
Steven Lord
Steven Lord il 31 Lug 2017
Do not use det to try to determine if a matrix is singular or near-singular!
In this example, A is a nonzero scalar multiple of the identity and as such is most definitely NOT singular. But dA is 0. Why? Underflow. The condition number, on the other hand, correctly identifies this matrix as well conditioned.
A = 0.1*eye(350);
dA = det(A)
cA = cond(A)
In this example the first and second rows of B are almost the same, and dB reflects this fact. But the magnitude of the elements in C (a nonzero scalar multiple of B) makes the determinant reasonably large so C appears to be nonsingular. But the condition numbers cB and cC tell the tale.
B = [1 1; 1 1+eps];
C = flintmax * B;
dB = det(B)
dC = det(C)
cB = cond(B)
cC = cond(C)
Ano
Ano il 1 Ago 2017
Thank you Steven Lord for replying to my question, I will take it into consideration . any suggestion on why I get the basic columns equal to 1 ??!!

Accedi per commentare.

Risposte (0)

Categorie

Scopri di più su Sparse Matrices in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by