matlab pinv 实现_伪逆的手动计算与Matlab中的pinv不同

I had a matrix D which is m*n and i am calculating the pseudo inverse using the formula inv(D'*D)*D' but it is not generating the same result as pinv(D).I need the term inv(D'*D) which i require for incremental operation. My all accuracy depends upon inv(D'*D) which is not correct. Is there any alternate way to get inv(D'*D) accurately? can any one help me please?

% D is 3x4 matrix that i had copied from one blog just for demonstration purpose. Actually original one of mine also had same problem bu its size is too large that i can't post it here.

D = -[1/sqrt(2) 1 1/sqrt(2) 0;0 1/sqrt(2) 1 1/sqrt(2);-1/sqrt(2) 0 1/sqrt(2) 1];

B1 = pinv(D)

B2 = D'*inv(D*D')

B1 =

-0.353553390593274 0.000000000000000 0.353553390593274

-0.375000000000000 -0.176776695296637 0.125000000000000

-0.176776695296637 -0.250000000000000 -0.176776695296637

0.125000000000000 -0.176776695296637 -0.375000000000000

Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND =

1.904842e-017.

B2 =

-0.250000000000000 0 0.500000000000000

-0.500000000000000 0 0

0.250000000000000 -0.500000000000000 0

0 0 -0.750000000000000

I need inv(D'D) to do incremental operation. Actually in my problem at step 1, each time a new row will be added to the last position of D and in step 2 first row of the D will be removed. So i want to find final D inverse using the inverse which i calculated before these two steps. More precisely have a look here:

B = inv(D'*D); % if i can calculate it accurately then further work is as follows

D1 = [D;Lr]; %Lr is last row to be added

BLr = B-((B*Lr'*Lr*B)/(1+Lr*B*Lr')); % Row addition formula

Fr = D1(1,:); % First row to be removed

D2 = removerows(D1,1);

BFr = BLr+ ((BLr*Fr'*Fr*BLr)/(1-Fr*BLr*Fr')); % row deletion formula

B = BFr;

Y = BFr*D2;

解决方案

The formulae (D^T D)^-1 D^T or D^T (D D^T)^-1 you are using for the Moore-Penrose pseudoinverse are only valid if D has full column or full row rank, respectively.

This is not true in your case, as the warning "Matrix is close to singular" shows.

The matlab pinv command works for arbitrary D, even if the matrix has neither full row or full column rank.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值