a matematical problem with matrix inversion

6 visualizzazioni (ultimi 30 giorni)
Zahra
Zahra il 9 Ago 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

Risposte (2)

Sean de Wolski
Sean de Wolski il 9 Ago 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 il 9 Ago 2011

Categorie

Scopri di più su Creating and Concatenating Matrices in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by