LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to fit a polynomial if XY waveform cluster is present

Solved!
Go to solution

Hello. I am quite new to LabView and I am improving one huge VI. It is a spectrometer application. I need somehow to add a polynomial fit to a XY graph of final results. However I am not sure how to handle cluster, how to separate it to X and Y data points to make a fit and then how to combine, to have additional fitted plot on top of data points. Please take a look at attached picture.

 

Do you have any ideas how could I do it?

 

Thanks!

0 Kudos
Message 1 of 8
(3,090 Views)

Xy graph accept a large number of possible datatypes, but getting an X array and Y array of one of the plots is easy.

 

Can you attach your actual VI instead?

 

Later you can create a new plot using a suitable x array, the found coefficients and "polynomial evaluation".

 

 

0 Kudos
Message 2 of 8
(3,076 Views)

Thanks altenbach for your reply. Particular VI is a part of a project which I am not allowed to distribute. I have enclosed Grafikas.vi, where XY chart is present on which I would like to see a fit as well, and graph - Copy.vi where combination of X and Y values to cluster occur.

 

Data which flows to waveform chart is: 1D array of cluster of 2 elements: both are 1D array. So my main questions is how to extract those two elements and use for fitting? Then  for example I could combine general polynomial fit output with X values to make another cluser of 2 elements. But then how to stream it to the same waveform chart?

 

 

0 Kudos
Message 3 of 8
(3,070 Views)
Solution
Accepted by Astravas

Well, your codeis just blistering with unecessary local variables and race condtions, so I decided to not touch it, but simply show the general procedure. See if it fits your need.

 

Download All
Message 4 of 8
(3,062 Views)

Awesome, thanks!

 

I was wondering, why not to use Best polynomial fit output as Y values, and then to combine it with X values, to make a chart?

0 Kudos
Message 5 of 8
(3,049 Views)

Astravas wrote:

I was wondering, why not to use Best polynomial fit output as Y values, and then to combine it with X values, to make a chart?


(Make sure you don't confuse charts and graphs. Charts have a special meaning in LabVIEW)

 

You can do that, but in my example the fitted cure would not look as smooth, because it would only connect the values of the existing x-values with straight line segments. See the green curve below. Try it!

 

 

0 Kudos
Message 6 of 8
(3,039 Views)

Oh yes, clever, thanks!

0 Kudos
Message 7 of 8
(3,035 Views)

And if you are as confused as me how the polynomial evaluation function is currently decorated, feel free to kudos my idea. 😄

0 Kudos
Message 8 of 8
(3,024 Views)