如何在MATLAB中找到两个矩阵之间的最小二乘法?

问题描述

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

add_executable(target main.cpp)
target_link_libraries(target nng::nngpp)

如果

粗麻布 = [-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 特征提取的定位错误

nng::nngpp

解决方法

x = numpy.linalg.lstsq(A,B)[0]

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

在 MATLAB 中你用

计算这个解
x = A\B;

the documentation

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

x = lsqr(A,B);