简体   繁体   English

pinv结果diff - matlab

[英]pinv result diff - matlab

As part of our homework we need to map imageA into iamge B 作为我们作业的一部分,我们需要将imageA映射到iamge B.
I'm using this code for inverse mapping 我正在使用此代码进行逆映射
A = zeros(8,8);
A = [imageB(1,1) imageB(2,1) 0 0 1 0 (-1)*(imageB(1,1)) imageA(1,1) (-1) (imageB(2,1)) imageA(1,1);
0 0 imageB(1,1) imageB(2,1) 0 1 (-1)
(imageB(1,1)) imageA(2,1) (-1) (imageB(2,1)) imageA(2,1);
imageB(1,2) imageB(2,2) 0 0 1 0 (-1)
(imageB(1,2)) imageA(1,2) (-1) (imageB(2,2)) imageA(1,2);
0 0 imageB(1,2) imageB(2,2) 0 1 (-1)
(imageB(1,2)) imageA(2,2) (-1) (imageB(2,2)) imageA(2,2);
imageB(1,3) imageB(2,3) 0 0 1 0 (-1)
(imageB(1,3)) imageA(1,3) (-1) (imageB(2,3)) imageA(1,3);
0 0 imageB(1,3) imageB(2,3) 0 1 (-1)
(imageB(1,3)) imageA(2,3) (-1) (imageB(2,3)) imageA(2,3);
imageB(1,4) imageB(2,4) 0 0 1 0 (-1)
(imageB(1,4)) imageA(1,4) (-1) (imageB(2,4)) imageA(1,4);
0 0 imageB(1,4) imageB(2,4) 0 1 (-1)
(imageB(1,4)) imageA(2,4) (-1) (imageB(2,4))*imageA(2,4)];
imageA(1,4); imageA(2,4)];
B = reshape(imageA,[],1);

D = pinv(A)*B;


my friend however uses this code : 然而,我的朋友使用此代码:
D = inv(A'*A)*A'*B;


i get the same values as he does except i get 0.0000 and he get -0.0000 all the rest of the numbers positive or negative are the same. 我获得与他相同的值,除了我得到0.0000并且他得到-0.0000所有其余数字的正数或负数都是相同的。

why is this ? 为什么是这样 ? and what is the correct answer? 什么是正确的答案?
what do you suggest i can do in order to check my results easly? 你有什么建议我可以轻松检查我的结果?

It seems like these differences stem from numerical instabilities. 看起来这些差异源于数值不稳定性。 How big are they with respect to machine precision ( eps )? 它们在机器精度( eps )方面有多大? Why don't you use backslash ? 你为什么不用backslash

>> D = A \ B;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM