LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Trouble using curve fitting in Labview

Hi,
I'm having some troubles with a program I'm trying to write in
LabView. I want to read a spreadsheet file with some data and plot
this in an XY graph. So far so good. But I'd also like to do a curve
fitting for my data and plot this in the same XY graph as the "raw"
data. How do I get my fitted curve into the graph? Say I want to use
Polynomial fit for example; I can't it to work.

Also, as a second question. How can I take the values from a cursor I
have in my graph and differentiate those? I want the program to show
the derivate of the cursor value.
Thnx in advance
/ Pierre

0 Kudos
Message 1 of 4
(3,295 Views)
XY graphs take quite a collection of data arrangements, so here is one possibility. I assume you create a cluster of the X and Y array for the xy graph. In this case, you're already almost there. Just create a second cluster for X and your fit and then use "built array" to combine the two clusters into an array. Feed the array to the terminal of the xy graph.
 
Open your example finder and loop for "Regression demo"
 
I assume you want to show the derivative of the fitted curve. (Taking the derivative of noisy data is a bit more difficult). Since you have the polynomial coefficients, you can easily create a formula that calculates the derivative from any given x, knowing the coefficients. Simply read the cursor x value using a property node, plug it into the derivative formula, and display the results.
 
What is your LabVIEW version?
0 Kudos
Message 2 of 4
(3,291 Views)
On 4 Feb, 18:40, altenbach <x...@no.email> wrote:
> XY graphs take quite a collection of data arrangements, so here is one possibility. I assume you create a cluster of the X and Y array for the xy graph. In this case, you're already almost there. Just create a second cluster for X and your fit and then use "built array" to combine the two clusters into an array. Feed the array to the terminal of the xy graph.
> &nbsp;
> Open your example finder and loop for "Regression demo"
> &nbsp;
> I assume you want to show the derivative of the fittedcurve. (Taking the derivative of noisy data is a bit more difficult). Since you have the polynomial coefficients, you can easily create a formula that calculates the derivative from any given x, knowing the coefficients. Simply read the cursor x value using a property node, plug it into the derivative formula, and display the results.
> &nbsp;
> What is yourLabVIEWversion?

Thnx alot
I got some more questions about the differentiation. How do I get the
coefficients? I know the "output" from the fitted curve is there, but
how do I send these to the "formula" part of the differentiation VI?
And since I'm a total newbie at this, I've never used a property node
before =)...all thelp is really appreciated
BTW, my version is 7.1

0 Kudos
Message 3 of 4
(3,287 Views)

The polynomial fit also gives you the coefficients in another output, check the online help. You can use these coefficients to calculate the fitted curve with different, or more x-values as needed using polynomial evaluation. Same for the first derivative (slope).

For the cursor position, simply create a property node linked to the xy graph, set it to read mode, and select property cursor.postionX.

The attached example (LabVIEW 7.1) does a polynomial fit, shows the fitted curve and it's first derivative for 128 points, and displays the slope wherever you place the cursor. Simply modify for your exact requirements. 🙂

(It would need error handling, e.g. to detect if the number of points is large enough for the desired polynomial order, for example)

0 Kudos
Message 4 of 4
(3,277 Views)