LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Lookup Table - Flexible from txt file

Solved!
Go to solution

Hi everyone, 

 

I have two txt files that have 1-D array each. I need to prepare a look up table that maps both files. Do you have any idea? I am new to LabVIEW. 

Also, the two files don't necessary always have the same number of elements, it depends on the test plan. the txt files are generated by another LabVIEW program. 

One more thing, the value that the program should find doesn't necessary to be found, so It should be calculated based on the relation between the nearest point and the desired output. 

 

I am open for other ideas as well! 

0 Kudos
Message 1 of 8
(2,462 Views)

Hi Ahmed,

 


@AhmedAl-Omoush wrote:

I have two txt files that have 1-D array each. I need to prepare a look up table that maps both files. Do you have any idea? I am new to LabVIEW.


Use Threshold1DArray. Prepare an array of [XY] points before calling this function - don't forget to read its help!

 


@AhmedAl-Omoush wrote:

Also, the two files don't necessary always have the same number of elements, it depends on the test plan.


Please provide an example for that use case of "different number of elements", together with examples of expected output for given input values!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 8
(2,459 Views)

Hi GerdW, 

 

attached are the two txt files. for example I need to find the y value of -6 as x-value.this should be calculated based on the nearest point or the function that related x &y. 

 

for numbe rof elements, here in the txt files, they have 4-elements, but this is variable and could be 29 or 16 or any random number. 

 

Best, 

Ahmed 

Download All
0 Kudos
Message 3 of 8
(2,451 Views)
Solution
Accepted by topic author AhmedAl-Omoush

Hi Ahmed,

 

what have you tried so far?

Where are you stuck?

Mind to attach your current VI?

 


@AhmedAl-Omoush wrote:

for example I need to find the y value of -6 as x-value.this should be calculated based on the nearest point or the function that related x &y.


  1. Read the "x.txt" using ReadDelimitedSpreadsheet, get the first column from the 2D array.
  2. Read the "y.txt" using ReadDelimitedSpreadsheet, get the first column from the 2D array.
  3. Combine both 1D arrays using Index&BundleClusterArray into an array of points.
  4. Use Threshold1DArray with this XY point array and your x_i=6 as inputs to get the corresponding y_i value…

Just 4 easy steps: please try on your own!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 8
(2,413 Views)

My problem is with matching the value. 

Here I tried different value but it always refers to the first element in the column (89.2) 

0 Kudos
Message 5 of 8
(2,403 Views)

@AhmedAl-Omoush  ha scritto:

My problem is with matching the value. 

Here I tried different value but it always refers to the first element in the column (89.2) 


Threshold 1D Array works with non-descending series of values (see the Help).

In your example, you should reverse both X and Y arrays before processing.

P.S.: if X and Y are related in a graph, I don't see how the number of ordinates could be different from the number of abscissas

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 6 of 8
(2,390 Views)
Solution
Accepted by topic author AhmedAl-Omoush

Hi Ahmed,

 

there are two problems with your VI:

  1. you forgot to take step 3 from my description
  2. your data don't follow the requirements given in the LabVIEW help description of the Threshold1DArray function: did you read the help?

 

See this:

This is a (quick &) very dirty solution to your problem.

Please follow pincpanters suggestion, read the LabVIEW help as suggested by me - and provide the data in those text files in a compatible way for the Threshold function!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 7 of 8
(2,389 Views)

Thank you! much appreciated. Now it's working 

0 Kudos
Message 8 of 8
(2,378 Views)