01-18-2013 02:53 PM
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.
01-18-2013 03:10 PM
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
01-18-2013 03:51 PM
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
01-18-2013 04:06 PM
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.
01-18-2013 04:09 PM
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
01-18-2013 04:15 PM
I understand what the program is doing. It does both the interpolation and extrapolation.
I don't want extrapolation.
01-18-2013 05:04 PM
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.
01-18-2013 06:23 PM
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
01-18-2013 06:39 PM - edited 01-18-2013 06:40 PM
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)
01-18-2013 08:36 PM
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.