04-04-2011 12:50 PM
I am trying to find a best fit line that will work for sine waves and loops (hysteresis loops). I can get the sine wave just fine, but when I switch to a hysteresis it just puts a line across the middle (I assume because of the 2 y values for every x). I am doing data acquisition that will take in both forms and graph them. I tried a polynomial fit and it doesn't work at least the way I implemented it and I tried a few others but it looks like they are all function based. Also, my y values are coming out of a Bessel filter. I don't think this would be affecting anything but I thought I would put it in here incase it does.
Did I miss one that I haven't tried that works for my application?
Thanks
Patrick
04-04-2011 12:58 PM
There are probably many solutions.
One would be to also have two x-axis, one for each direction.
Can you attach a simple VI containing some typical data?
04-04-2011 01:09 PM
Hi,
I have been looking for a way to get a best fit sine wave, i want the result to be in the form y=sin(x) rather than a polynomial expression. currently I am doing it by looping and reducing the error towards zero to fit the amplitude and phase. (I know the frequency). If this is what you are looking to do then I will help, or should I be doing things differently? All of the functions I have found to filter or extract tones seem to introduce a larger frequency of phase error than i get using this method, but am I missing something?
Michael
04-04-2011 01:11 PM - edited 04-04-2011 01:17 PM
Do you want a CSV or LVM file with the sample data? The VI itself is a simple graph of that data. Buts it is within a much larger program that I can not post. I will post screenshots to try to give you a better idea.
04-04-2011 01:14 PM - edited 04-04-2011 01:17 PM
Michael,
You can use a Bessel filter that works pretty well. It will have a group phase lag, but it will be constant and you can either calculate it and eliminate it or use the zero phase Filter VI. Or you can use a running average to smooth it out without any phase lag. There are other ways, but these are how I filter my waves. It doesn't get them perfect, but it reduces the noise greatly.
I am looking for a perfectly smooth best fit line to use after the filters.
Patrick
04-04-2011 01:17 PM
@Patrick H. wrote:
Do you want a CSV or LVM file with the sample data?
csv is probably better. Or simple attach an empty VI with the data in a diagram constant.
04-04-2011
01:22 PM
- last edited on
11-07-2024
01:30 PM
by
Content Cleaner
RiversDaddy wrote:... currently I am doing it by looping and reducing the error towards zero to fit the amplitude and phase. (I know the frequency). If this is what you are looking to do then I will help, or should I be doing things differently? All of the functions I have found to filter or extract tones seem to introduce a larger frequency of phase error than i get using this method, but am I missing something?
"looping" is a bit vague. What is the actual algorithm to find better estimates (e.g. levenberg marquardt, etc.)
What problems did you have with extract single tone. Can you show some data where the results from it are not good?
04-04-2011 01:35 PM - edited 04-04-2011 01:37 PM
Here is a CSV of some sample data. Column 1 as X and 2 as Y for the wave and 3 as X and 4 as Y for the loop.
04-04-2011 01:39 PM
What is the point of the attached VI?
04-04-2011 01:41 PM
Crap it didnt save the VI when I finished. I had it seperated and ready to graph but I think I didn't save it or I did something wrong in the process.