从opt.leastsq分配结果变量的错误

发布于 2025-01-26 06:08:45 字数 587 浏览 3 评论 0原文

我正在设置一个内部定位系统,当我请求opt.leastsq函数时,我在字符串中具有预期的结果,但是它给了我输出错误。

这是我的代码:

x, y, _ = opt.leastsq(F, x0=[xp, yp], Dfun=J)

上面的代码总是给我错误:

x, y, _ = opt.leastsq(F, x0=[xp, yp], Dfun=J)
ValueError: not enough values to unpack (expected 3, got 2)

但是当我打印此功能时:

x = opt.leastsq(F, x0=[xp, yp], Dfun=J)
print(x)

它准确地给了我所期望的结果,除了坐标外的数字“ 2”外:

(array([4.6243258 , 4.23836195]), 2)

我很感激谁能帮助我组织我的组织代码将第一个值分配给变量x,第二个值分配给了变量y。如上所述,避免在我看来上述错误。

非常感谢您。

I'm setting up an interior positioning system, and when I request the opt.leastsq function, I have the expected result in the string, but it gives me an output error.

Here's my code:

x, y, _ = opt.leastsq(F, x0=[xp, yp], Dfun=J)

The above code always gives me the error:

x, y, _ = opt.leastsq(F, x0=[xp, yp], Dfun=J)
ValueError: not enough values to unpack (expected 3, got 2)

But when I print this function:

x = opt.leastsq(F, x0=[xp, yp], Dfun=J)
print(x)

It gives me exactly the result I expect, with the exception of the number "2" outside the coordinate:

(array([4.6243258 , 4.23836195]), 2)

I appreciate who can help me organize my code to have the first value assigned to the variable x, and the second value assigned to the variable y. Avoiding that the said error appears to me as mentioned above.

Thank you very much in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

红尘作伴 2025-02-02 06:08:45

多亏了HPAULJ指南,能够在两个变量“ x”和“ y”中调整结果值。我在这里留下了我所做的过程,并且可以正常工作。我希望对有同样问题的其他人有帮助。
我提取值并将它们放在另一个我称为“ potit”的变量

posit, _ = opt.leastsq(F, x0=[xp, yp], Dfun=J)

x, y = np.split(posit, 2, axis=0)
print("x = ",x)
print("y = ",y)

首先, 能够在“ x”和“ y”坐标中分别处理值。

x =  [3.40314229]
y =  [0.79129237]

Thanks to hpaulj guidelines, being able to adjust the values of the result in two variables "x" and "y". I leave here the process that I did and it works correctly. I hope to be of help to others who have the same question.
First I extract the values and place them in another variable which I called "posit"

posit, _ = opt.leastsq(F, x0=[xp, yp], Dfun=J)

Then using the "splint" function I set the coordinate values for each variable ("x" and "y")

x, y = np.split(posit, 2, axis=0)
print("x = ",x)
print("y = ",y)

So I get the expected result, now being able to handle the values separately exactly in the "x" and "y" coordinates.

x =  [3.40314229]
y =  [0.79129237]
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文