a matematical problem with matrix inversion
6 views (last 30 days)
Show older comments
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
0 Comments
Answers (2)
Sean de Wolski
on 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
0 Comments
See Also
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!