从opt.leastsq分配结果变量的错误
我正在设置一个内部定位系统,当我请求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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
多亏了HPAULJ指南,能够在两个变量“ x”和“ y”中调整结果值。我在这里留下了我所做的过程,并且可以正常工作。我希望对有同样问题的其他人有帮助。
我提取值并将它们放在另一个我称为“ potit”的变量
中
首先, 能够在“ x”和“ y”坐标中分别处理值。
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"
Then using the "splint" function I set the coordinate values for each variable ("x" and "y")
So I get the expected result, now being able to handle the values separately exactly in the "x" and "y" coordinates.