a matematical problem with matrix inversion

6 Ansichten (letzte 30 Tage)
Zahra
Zahra am 9 Aug. 2011
Hi all; i have a simple and stupid problem!! consider u is a non-squared matrix, why the following equation is not equal to Identity matrix when executing in MATLAB:
U' * inv( U * U') *U
Thanks in advance, Z.Z

Antworten (2)

Sean de Wolski
Sean de Wolski am 9 Aug. 2011
U = magic(4); %sample data
U = U(:,1:3); %non-square it
U'*(( U * U')\U) %see what happens:
ans =
1 -9.7145e-17 2.0817e-16
2.0817e-17 1 -1.6653e-16
1.3878e-17 8.3267e-17 1
the 10^-16 is just an artifact of floating point calculations. For all intensive purposes, the above is a 3x3 identity matrix.
Don't use inv, use '\'.
doc mldivide
Also, this for floating point explanation: FAQ6.1

Walter Roberson
Walter Roberson am 9 Aug. 2011

Kategorien

Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by