LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Double interpolation problem

I am having a problem interpolating numbers from a table using an angle and other measurement from instruments. By doing tests I came up with a calibration table that allows me to get a distance measurement. I know that the program I attached works, but the table I have doesn't work because the numbers in my table decrease from left to right. I need a program to interpolate the table. Is there a way to change the program to correct the problem or another way to interpolate.

 

PS This program contains test code and dosen't contain the full calibration table and instead of data feeds controls were used to simplify it  

0 Kudos
Message 1 of 9
(3,904 Views)

Hi Ben,

 

For a double (bilinear) interpolation, rather than using several 1-D Interpolation VIs , you can use the “Interpolate 2D” VI. It is located on the functions palette under Mathematics -> Interpolation & Extrapolation. For the example you posted you would need to choose the (1D xi, yi) instance once it is placed on your block diagram. Be sure to set method to bilinear—Sets the interpolated values to points along the line segments that connect X and Y. Z is the dependent variable (2D array), X and Y are your independent variables (1D arrays), xi and yi are the values you are trying to interpolate for (1D array).

 

In your example code, Z = Apparent Distance, X = Angle, Y = Distance. Unfortunately if you are trying to generate distance, a traditional bilinear interpolation won’t work properly, as it can only interpolate the dependent variable (in your case Apparent Distance). If you need to use bilinear interpolation for Distance, you would have to solve the bilinear interpolation equations manually for an independent variable (and build resulting equations manually on your block diagram).

Evan See
National Instruments
0 Kudos
Message 2 of 9
(3,841 Views)

hi ben,

 

I would an alternative way to offer, using a vi from the waveform palette:

 

2013-07-03_resample.png

 

 

this would be one possible result:

2013-07-03_front-resample.png

 

 

 

Regards,
Alex

0 Kudos
Message 3 of 9
(3,821 Views)

I need my code to work exactly how I allredy have it set up so the built in VI's won't work. What I alredy have works except it dosen't like that my numbers decrease from left to right. I slightyly altered my program with just adding numbers in front of the decimals so the numbers increase left to right and it works. I can not alter the tabeles at all. mayby I can add a custom equation to corect the problem I have.

 

Thanks for you time.

0 Kudos
Message 4 of 9
(3,811 Views)

Hi Evan,

 

I followed your advice and found out what part of my code didn't work and replaced it with a formula node. Yet the program dosen't whant to run with my formula node in it. So I kept simplifying the script till I could find out what was wrong and it still wouldn't work so I ended up just copying a simple example I found for lab view online yet it still didn't work. Atteched are two programs the first one has the full script the second is the simplified one. Both don't work can you help.

 

Ben  

Download All
0 Kudos
Message 5 of 9
(3,783 Views)

if you delete the first row or replace int64 with float64 in the formula node of double interpolation (2).vi ‏9 KB,

you will be able to run the vi

 

1.png      2.png

 

 

OR:

5.png

 

 

 

 

this is the general syntax:

 

if (y==x && a[2][3]<a[0][1]) {
     int32 temp;
     temp = a[2][3];
     a[2][3] = y;
     y=temp;
     }
else
     x=y;

 

http://zone.ni.com/reference/en-XX/help/371361J-01/lvhowto/formula_node_syntax/

 

 

and this is an example for a multi-conditional statement:

http://digital.ni.com/public.nsf/allkb/26F9FFCAEB9A97CB862568F900719F74

 

 

 

 

0 Kudos
Message 6 of 9
(3,775 Views)

here we go for double interpolation (1).vi ‏10 KB :

 

besides deleting the row with int64 Y; btw you would need float64, won't you?

 

1# there are too much ( )

2# it's && not and

3# the formula node is case sensitiv, so x3 ≠ X3

 

3.png           4.png

0 Kudos
Message 7 of 9
(3,773 Views)

Thanks for your help my program works now. I am ataching it in case your interested.

 

Ben

0 Kudos
Message 8 of 9
(3,746 Views)

@Ben128 wrote:

Thanks for your help my program works now. I am ataching it in case your interested.

 

Ben


yes, I am!

 

 

thanks

0 Kudos
Message 9 of 9
(3,735 Views)