07-02-2013 05:27 PM
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
07-03-2013 12:59 PM
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).
07-03-2013 03:56 PM - edited 07-03-2013 03:56 PM
hi ben,
I would an alternative way to offer, using a vi from the waveform palette:
this would be one possible result:
Regards,
Alex
07-03-2013 04:51 PM
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.
07-05-2013 10:50 PM
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
07-06-2013 05:53 AM - edited 07-06-2013 06:15 AM
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
OR:
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
07-06-2013 06:06 AM - edited 07-06-2013 06:11 AM
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
07-07-2013 02:17 PM
Thanks for your help my program works now. I am ataching it in case your interested.
Ben
07-07-2013 03:42 PM
@Ben128 wrote:
Thanks for your help my program works now. I am ataching it in case your interested.
Ben
yes, I am!
thanks