07-16-2012 02:04 AM
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!
Solved! Go to Solution.
07-16-2012 11:29 AM
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".
07-16-2012 12:25 PM - last edited on 07-16-2012 01:31 PM by MaryH
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?
07-16-2012 01:06 PM - edited 07-16-2012 01:07 PM
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.
07-16-2012 01:28 PM
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?
07-16-2012 01:52 PM - edited 07-16-2012 02:04 PM
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!
07-16-2012 02:02 PM
Oh yes, clever, thanks!
07-16-2012 06:35 PM
And if you are as confused as me how the polynomial evaluation function is currently decorated, feel free to kudos my idea. 😄