LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

wrong data after 1D interpolation

Hi.I am using LabView 2012.

I have a small question about 1D interpolation. Say my X array input has a range between 0-100. Then I use another array xi with a range of 0-200. Then the value for xi from 100-200 is totally undetermined, And depending on which method you choose to interpolate, it could be an linear extrapolation (linear and spline), or a constant (nearest), or something strange (Lagrange). 

This doesn't make sense to me because when xi is out of range of X, I would expect it to be a default value (such as 0 or null) rather than extrapolate to some strange result. I can change that myself easily in the program, but I think the LabView should do it by default. 

 

Here I have a small program demo.  

 

0 Kudos
Message 1 of 10
(3,761 Views)

Actully that is the correct, expected, behavior the average slope X and Y is 1 so yi of xi [199] is 199.  As a proof change the 100 constant to anything greater than 1


"Should be" isn't "Is" -Jay
0 Kudos
Message 2 of 10
(3,753 Views)

You are right. I didn't say the program is wrong.

What I mean is the way the 1D interpolate works doesn't make sense to me. If I am taking data, and I only want my original data "interpolated", not "extrapolated". But some how I don't know exactly what is the range of X array, so I will use a large Xi array to ensure it covers the range of X array. Then this 1D interpolation will give the wrong data. 

Of course you can program it so whatever is out of range of X array will be thrown away, or each time make sure Xi array is the same range as X array. But this will take some extra programming work, and inefficient. Why don't LabView do this automatically inside the ID interpolation function? I read the code "in_1d interp.vi" and it has a judgement if Xi element is in the range, it can be easily done inside the function.

Or is this not usually the case and people don't care the extrapolation?

 

regard

 

Qi

0 Kudos
Message 3 of 10
(3,741 Views)

In another word, the 1D interpolation did both "interpolation" and "extraploation". But sometime or most of time I only want interpolation even the Xi array I wired is out of range of X array. 

0 Kudos
Message 4 of 10
(3,731 Views)

That's just how interpolation is done

Find a set yi for set xi that would make it similar to the set X,Y  and do so in interpreting X, Y linearly.  the relationship is X = Y with a slope of 1 and intercept of 0 so for any value in xi yi will be xi *1 +0


"Should be" isn't "Is" -Jay
0 Kudos
Message 5 of 10
(3,728 Views)

I understand what the program is doing. It does both the interpolation and extrapolation. 

I don't want extrapolation.

0 Kudos
Message 6 of 10
(3,723 Views)

Then you will have to use a case structure to give you a whatever different result you want when you determine your value is outside of the X range.

0 Kudos
Message 7 of 10
(3,716 Views)

Yes. I can do that easily. 

I am just feeling misleading. The function called 1D "Inter"polated, why does it do extrapolation?

Anyway, it is my thought, probably not worthing time of further discussion. Thanks for all the reply. 

Reards

 

Qi 

0 Kudos
Message 8 of 10
(3,713 Views)

Note that the pallete is actually called Interpolation & Extrapolation VIs so extrapolation is implicitely included. 😄 (only "polynomial" and "rational" explicitely mention extrapolation).

 

I agree that extrapolation could be mentioned more prominently in the individual help sections, but it is certainly a good default behavior, especially if you are close to the valid X range. Dropping hard to the data default (or e.g. NaN) would probably be worse. 😉 If you are concerned, you need to do some range checking.

 

(note that "interpolate array" from the array palette (only linear intepolation) actually has a different behavior outside the valid range, so you might check that out as an alternative)  

0 Kudos
Message 9 of 10
(3,709 Views)

Thanks for informing that the pallette is called "  Interpolation & Extrapolation VI

Haha. 

 

It is a problem for me because when I take experimental data, there should never be an extrapolation since those are not real data. 

 

 

0 Kudos
Message 10 of 10
(3,697 Views)