LabView cos 拟合
我正在开发一个程序,需要拟合大量余弦波才能确定该函数的参数之一。我使用的方程是 y = y_0 + Acos((4*pi*L)/x + pi) 其中 L 是我试图从最佳拟合线获得的值。
我知道可以对每组数据手动正确执行此操作,但是自动化此过程的最佳方法是什么?我当前正在从文本文件中读取数据,并运行一个循环,初始参数不断变化,直到我拥有一组振幅与数据相似的参数值,然后我检查中心峰值上的点之间的百分比差异两个末端峰,尝试挑选最好的一个。它始终选择比我手动安装时得到的值更低的值(几乎恰好是一个阶段)。那么有没有办法改进这个方法,或者有其他效果更好的方法呢?
编辑:我的LabVIEW版本有一个cos拟合VI,这就是我正在使用的,问题是当我尝试通过使用循环更改初始参数来自动化拟合时,我不知道如何让程序选择相同的最佳值符合人类选择的线。
I am working on a program that needs to fit numerous cosine waves in order to determine one of the parameters for the function. The equation that I am using is y = y_0 + Acos((4*pi*L)/x + pi) where L is the value that I am trying to obtain from the best fit line.
I know that it is possible to do this correctly by hand for each set of data, but what is the best way to automate this process? I am currently reading in the data from text files, and running a loop with the initial paramiters changing until I have an array of paramater values that have an amplitude similar to the data, then I check the percent difference between points on the center peak and two end peaks to try to pick the best one. It in consistently picking lower values than what I get when fitting by hand (almost exactly one phase off). So is there a way to improve this method, or another method that works better?
Edit: My LabVIEW version has a cos fitting VI which is what I am using, the problem is when I try to automate the fitting by changing the initial parameters using a loop, I cant figure out how to get the program to pick the same best fit line as a human would pick.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
为什么不直接使用快速傅立叶变换呢?这应该比拟合余弦要快得多。在复数结果向量中查找总数中的最大峰值。您将获得频率(FFT 结果向量中的位置)、幅度和相位。
Why not just use a Fast Fourier Transform? This should be way faster than fitting a cosine. In the result vector of complex numbers look for the largest peak of in the totals. You're given frequency (position in the FFT result vector), amplitude and phase.
您可以通过计算拟合曲线与数据之间的差异来评估拟合的优劣。 VI 在“高级曲线拟合”选项板中执行此操作。然后您所要做的就是选择最合适的。
You can evaluate the goodness of the fit by computing the difference between fitting curve and your data. A VI does this in the "Advanced curve fitting" palette. Then all you have to do is pick up the best fit.