我遵循wiki上的公式:
http://en.wikipedia.org/wiki/Pseudo_inverse
计算伪逆,但我无法收到正确的结果。例如:我想找到theta
方程:Y=R*theta
,我在matlab上写:
R = -[1/sqrt(2) 1 1/sqrt(2) 0;0 1/sqrt(2) 1 1/sqrt(2);-1/sqrt(2) 0 1/sqrt(2) 1];
% R is 3x4 matrix
Y = [0; -1/sqrt(2);-1]; %Y is 3x1 matrix
B1 = pinv(R);
theta1 = B1*Y;
result1 = R*theta1 - Y
B2 = R'*inv(R*R');
theta2 = B2*Y;
result2 = R*theta2 - Y
这是结果:
result1 =
1.0e-15 *
-0.1110
-0.2220
-0.2220
Warning: Matrix is close to singular or badly scaled.
Results may be inaccurate. RCOND = 1.904842e-17.
> In pseudoinverse at 14
result2 =
0.1036
-0.1768
-0.3536
显然,theta2 是错误的答案,但我不知道如何以及为什么。我读了很多书,他们给了我与 wiki 相同的公式。有人可以帮我手工做伪逆吗?谢谢 !