LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

extrapolation problems

Solved!
Go to solution

Hello.

 

I am plotting data from 8 curves (x has fixed points, y has from 1-8 valid points)

Where the values have gone over-scale i have forced NaN into the y array.

I need to extrapolate y down to x=0

Now when i use the (polynomial or rational) interpolation vi it ignores any of the curves which have NaN in them. I had hoped it would just ignore those values.

 

Can anyone think of a work-around? or alternative method?

 

(screenshot attached)plots.jpg

 

Labview 2010, TestStand 2010
0 Kudos
Message 1 of 10
(5,666 Views)

What do you mean by ignore? The graph will not plot a NaN point so you will see blank bits.

Are you trying to extend the lines on the graph down to x=0 or just get the value numerically?

 

As your data looks linear, I would feed the two arrays into the Linear Fit function to generate a slope and intercept. The intercept is the answer you require at x=0. This has the benefit of also providing you with the information to interpolate or extrapolate to any point on the line... allowing you to define any two points and plot the corresponding line between them

 

Obviously if your data is not linear, you need to take a bit more care!

 

As an extra thought, do you really need to force the out-of range elements to NaN - what is wrong with their out-of-rangeness, does it affect your interpolation?

 

Ian

0 Kudos
Message 2 of 10
(5,655 Views)

Hi, I dont mean that the graph function is ignoring the NaN but as can bee seen the Interpolate (extrapoltae) function does not perform any extrapolation on the datasets that have NaN within them which i find surprising.

 

The data is theroetically linear, with of course real-world errors, I will try the Linear fit function.

 

If the values were left out of range it would make the extrapolation incorrect, as the value saturates.

 

Labview 2010, TestStand 2010
0 Kudos
Message 3 of 10
(5,647 Views)

Linear fit does the same - i.e. If there are any NaN points in the data, the fit is not performed.Or at least i get no intercept value out.

 

Labview 2010, TestStand 2010
0 Kudos
Message 4 of 10
(5,645 Views)

You will need two sets of arrays.  One as you have now will have the NaN for the plots.  The other (perhaps your raw data) will only contain the valid data points.  Use the one with the valid points for the Linear Fit.  You may also need to create an X array with only the X values for the valid points.

 

It appears that your arrays are small so this should not become a memory burden.

 

Lynn

0 Kudos
Message 5 of 10
(5,638 Views)

Or i suppose i retain just one array, but truncate it at the first occurence of a NaN..?

 

Another related question - How would i find the convergence point (x,y) of these 8 curves?

Labview 2010, TestStand 2010
0 Kudos
Message 6 of 10
(5,630 Views)

That should work as long as you do not have any more valid data points later.

 

If you have the equations of the straight lines, you can do the math to find the intersections.  In general 8 lines will not intersect at exactly the same point, particularly after you allow for noise and truncation error in the data collection.  You could find the intersections of each pair of wires and then get the centroid of the set of intersections.  If some data sets are "better" than others you might weight intersection with those lines more heavily than "poorer" data sets.  For example a 3-point curve may have a larger error than a 7-point curve.

 

If you have knowledge about the behavior of the system which generates this data, you may be able to use it to improve the accuracy of your estimate of the convergence point.

 

Lynn

0 Kudos
Message 7 of 10
(5,616 Views)

I dont have the equations, just the measured data you see.

 

And I'll admit to not being the strongest mathematician you've ever met.

How can i derive the crossing point (x,y) of just 2 of these lines for example?

Labview 2010, TestStand 2010
0 Kudos
Message 8 of 10
(5,610 Views)
Solution
Accepted by topic author Hoss183

You may want to refresh your mathematics.  To define the "best" convergence point estimate may require some understanding of the mathematics involved.

 

The intersection of two straight lines:

 

Let the lines be represented in slope-intercept form with slopes m1 and m2 and intercepts b1 and b2:

 

y = m1*x + b1

y = m2*x + b2

 

Solving for x gives x = (b2 - b1)/(m1 - m2).

 

Substituting back into the first equation gives y = m1*(b2 - b1)/(m1 - m2) + b1.

 

Notice that the x and y values of the intersection point only depend on the slopes and intercepts, which you can get directly from the linear fit.

 

Lynn

Message 9 of 10
(5,602 Views)

Thanks Lynn, that works a treat.

 

Just for closure - I trucated the arrays at (before) the first instance of NaN, and then passed through the linear fit vi. Then used Lynn's equations to deternmine the crossover of the lines.

Labview 2010, TestStand 2010
0 Kudos
Message 10 of 10
(5,594 Views)