【问题标题】:How do I find least square between two matrix in MATLAB?如何在MATLAB中找到两个矩阵之间的最小二乘?
【发布时间】:2021-09-20 20:18:03
【问题描述】:

在 MATLAB 中,python 中以下代码 sn-p 行的替换是什么? 来自Python Implementation for SIFT Feature Extraction

 x = -lstsq(hessian, gradient, rcond=None)[0]

如果

粗麻布 = [-0.001 -9.042 -9.491;-9.042 -2.345 -7.983;-9.491 -7.983 -7.269] 和梯度 = [1.6 6.1 9.3]

以下是当前在 MATLAB 中实现的,但给出了 SIFT 特征提取的定位错误

[U,S,V] = svd(hessian); %singular value decomposition for eigenvectors 
T=S;
T(S~=0) = 1./S(S~=0);  
invH = V .* T' .* U'; %inverse hessian
x = - invH.*gradient;

【问题讨论】:

    标签: python matlab feature-extraction sift hessian-matrix


    【解决方案1】:
    x = numpy.linalg.lstsq(A, B)[0]
    

    是线性方程 Ax=B 的解。如果超定或欠定,则返回最小二乘解。

    在 MATLAB 中,您可以使用

    x = A\B;
    

    the documentation

    要显式使用最小二乘求解器,请使用lsqr,这通常仅对稀疏矩阵有用:

    x = lsqr(A, B);
    

    【讨论】:

      猜你喜欢
      • 2017-09-28
      • 2016-03-03
      • 2019-03-08
      • 2015-12-17
      • 2016-01-14
      • 1970-01-01
      • 2011-10-31
      • 2018-08-31
      • 1970-01-01
      相关资源
      最近更新 更多