Matlab lsqcurvefit 适用于一些迭代,然后因错误而停止

发布于 2024-10-04 16:25:30 字数 853 浏览 0 评论 0原文

我正在尝试为由隐式函数定义的模型找到优化参数,以使用 fsolve 和 lsqcurvefit 拟合数据集。我在单独的 m 文件中定义了 3 个函数:第一个是要定义的 4 个参数中隐式函数的定义,第二个使用 fsolve 查找定义的隐式函数的根,第三个使用 lsqcurvefit 查找优化值为四个参数。我自然需要为参数定义足够好的初始值,但是在尝试了各种合理的组合后,lsqcurvefit总是运行大约20-30次迭代(matlab在每次迭代后打印出用fsolve找到的解计算出的向量值),然后打印

No solution found.

fsolve stopped because the problem appears regular as measured by the gradient,
but the vector of function values is not near zero as measured by the
default value of the function tolerance.

<stopping criteria details>

??? Error using ==> lsqcurvefit at 253
Function value and YDATA sizes are incommensurate.

Error in ==> optimointi at 5
z = lsqcurvefit('laske_i',parametrit,V_vektori,I_vektori_mitattu,[],[],options);

我看不出“函数值和 YDATA 大小不相称”。突然间,迭代首先运行了 20-30 次。每次迭代后打印的值几乎全是零(很好拟合),但最后几个“爆炸”从 0 到 1(系数为 10 的几次方)。对错误的任何帮助表示赞赏!

I'm trying to find optimized parameters for a model defined by an implicit function to fit a dataset using fsolve and lsqcurvefit. I have defined 3 functions in separate m-files: first one is a definition for the implicit function in 4 parameters to be defined, second one uses fsolve to find the roots of the implicit function defined and the third one uses lsqcurvefit to find optimized values for the four parameters. I naturally need to define good enough initial values for the parameters, but having tried various reasonable combinations, lsqcurvefit always runs for some 20-30 iterations (matlab prints out the vector values calculated with the solution found by fsolve after each iteration) and then prints

No solution found.

fsolve stopped because the problem appears regular as measured by the gradient,
but the vector of function values is not near zero as measured by the
default value of the function tolerance.

<stopping criteria details>

??? Error using ==> lsqcurvefit at 253
Function value and YDATA sizes are incommensurate.

Error in ==> optimointi at 5
z = lsqcurvefit('laske_i',parametrit,V_vektori,I_vektori_mitattu,[],[],options);

I can't see how "Function value and YDATA sizes are incommensurate." suddenly, as the iteration first runs for 20-30 times. The values printed after each iteration are pretty much full of zeros (good fit), but the last few 'explode' from 0 to 1 (with a coefficient of several powers of ten). Any help on the error appreciated!

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

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

发布评论

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

评论(2

蓝戈者 2024-10-11 16:25:30

错误在于 fsolve 的工作方式。实际起作用的是 fsolve,但我必须添加一个 for 循环,以使域向量的每个元素的 fsolve 结果也是一个向量。这就是为什么 Function value 和 YDATA 确实不相称的原因。

The error lies in how fsolve works. What actually worked was fsolve, but I had to add a for-loop to make the result of fsolve for each element of the domain vector also a vector. This is why Function value and YDATA really were incommensurate.

不及他 2024-10-11 16:25:30

就我而言, lsqcurvefit 中的错误“函数值和 YDATA 大小不相称”是由于我用作 Ydata 的向量造成的,这实际上是一件相当愚蠢的事情。
向量必须采用列形式 y=[1;2;3],而不是像 y=[1 2 3]。这导致了 lsqcurvefit 中的问题,因为 xdata 也像列

In my case, the error in lsqcurvefit that said "Function value and YDATA sizes are incommensurate" was due to the vector I was using as Ydata, it was quite a silly thing actually.
The vector must be in column form y=[1;2;3], not like y=[1 2 3].That was causing the problem in lsqcurvefit, because the xdata were like columns too

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