LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Best fit lines for loops and sine waves

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

0 Kudos
Message 1 of 17
(4,716 Views)

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?

0 Kudos
Message 2 of 17
(4,709 Views)

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

0 Kudos
Message 3 of 17
(4,704 Views)

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.

Download All
0 Kudos
Message 4 of 17
(4,701 Views)

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

0 Kudos
Message 5 of 17
(4,694 Views)

 


@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.

0 Kudos
Message 6 of 17
(4,688 Views)

 


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?

0 Kudos
Message 7 of 17
(4,684 Views)

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.

Download All
0 Kudos
Message 8 of 17
(4,675 Views)

What is the point of the attached VI?

0 Kudos
Message 9 of 17
(4,670 Views)

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.

0 Kudos
Message 10 of 17
(4,668 Views)