LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Compare array

Solved!
Go to solution

Good morning everyone, here's my problem: I have an .ini file from which I need to extract values (there are several lines, with two columns: the first column shows the lambda value (nm) and the second column shows the corresponding values). Based on the current lambda value, I need to be able to select the correct other value and then save it to the file. I am currently using the “Read from text file” VI to select the rows, so I end up with an array containing all the rows I need. How can I tell LabVIEW that if, for example, the current lambda is 202 nm, it should only take the value of the array corresponding to 202 nm? I have no problem opening the file and “unpacking” the array, but I don't understand how to compare the values. I hope you can help me. Thank you.

 

0 Kudos
Message 1 of 7
(185 Views)

Hi giuli,

You can explore comparison pallet and use either "equals to" or "in-range and coerce" function.  

0 Kudos
Message 2 of 7
(157 Views)

Words cannot really describe well what you actually want to do. But you seem to implement a simple lookup table.

 

  • Please attach a typical ini file.
  • Are the value integer or floating point? (com[paring floating point values is dangerous!)
  • So you want to save only one value to the file? What is the format?
  • Are the lines sorted by lambda?
  • What should happen if an exact lambda does not exist (find nearest? Interpolate? etc.)
  • etc.

If you have no problem "unpacking" (sic), why not attach your VI so we can get a better picture? It seems you are not really doing a "compare array", but searching one column. Not quite the same.

 

0 Kudos
Message 3 of 7
(150 Views)

Thanks for your reply! In the .ini file (I'm attaching an example), there are several lambda values (integers), and each one corresponds to a sensitivity value (E-14 format). The current lambdas in the program are in integer format, so they necessarily have a match in the file. I need the program to acquire the values from the .ini file and compare them with the current lambda. After finding the match, I need to save the exact sensitivity value. I hope I have explained myself clearly. I am attaching an example of VI (I am testing it before inserting it into the final program). As you can see, there is a while loop, so it does not exit until the exit condition (i.e., it has found the match) is met. Please forgive me, but I am still a beginner.

 

Download All
0 Kudos
Message 4 of 7
(116 Views)
Solution
Accepted by topic author giuli_

See if this can give you some ideas.

 

altenbach_0-1762965571565.png

 

 

(Please don't use a greedy loop that continuously reads the same file over and over again as fast as the computer allows.)

 

Message 5 of 7
(106 Views)

Thanks so much, I think it'll work. (The while loop was just a test, obviously.) The important thing is that for each value of lambda, it can calculate the value, and that's perfect. Have a good day.

0 Kudos
Message 6 of 7
(65 Views)

Of course you should also implement some error handing, for example you could return NaN if the entered lambda does not exist. Currently it would return zero.

0 Kudos
Message 7 of 7
(32 Views)