From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Optimization and Flexibility of code

Solved!
Go to solution

Hello everyone,

 

I'm stuck here for weeks, I have no idea how to optimize my code, and there's no flexibility too.

 

There are 20 products I need to analyze, each product has different parameters.
And there are 40 values in every parameters, so there would be 40*39=1560 vales in my file.

 

I have to compare each value in two files("preset file" and "analyze file"), if all of the values of Product 1 in "analyze file" are ≥ those in "preset file", then show the product number in array and calculate the percentage.

 

The values in the files are ranged according to the order as the table below:

Product Number Parameter Number Value in Parameter
Product 1 Para 23 40 valus
Para 45 40 valus
Product 2 Para 37 40 valus
Product 3 Para 28 40 valus
Product 4 Para 36 40 valus
Para 11 40 valus
Para 19 40 valus
Product 5 Para 30 40 valus
Product 6 Para 31 40 valus
Para 19 40 valus
Para 26 40 valus
Product 7 Para 40 40 valus
Product 8 Para 15 40 valus
Para 11 40 valus
Para 19 40 valus
Product 9 Para 19 40 valus
Para 16 40 valus
Para 13 40 valus
Product 10 Para 18 40 valus
Para 16 40 valus
Para 13 40 valus
Product 11 Para 31 40 valus
Para 23 40 valus
Product 12 Para 29 40 valus
Product 13 Para 17 40 valus
Para 16 40 valus
Para 14 40 valus
Product 14 Para 18 40 valus
Para 14 40 valus
Product 15 Para 39 40 valus
Product 16 Para 27 40 valus
Product 17 Para 15 40 valus
Para 13 40 valus
Product 18 Para 16 40 valus
Para 14 40 valus
Para 13 40 valus
Product 19 Para 19 40 valus
Para 17 40 valus
Product 20 Para 41 40 valus

My problem is if there's any efficient way to code, because the Values in Parameter will not always be 40, I need to analyze the 20, 60, 500 and 1000.

Any help would be greatly appreciated.

0 Kudos
Message 1 of 4
(1,134 Views)

Does your current code produce the correct result from the given data?

0 Kudos
Message 2 of 4
(1,093 Views)
Solution
Accepted by topic author edwardmax101

See if this can give you some ideas (result is the same!)

 

altenbach_0-1604875341950.png

 

(I am sure it can be further simplified. This is just a very quick attempt)

Message 3 of 4
(1,089 Views)

@edwardmax101 wrote:

My problem is if there's any efficient way to code, because the Values in Parameter will not always be 40, I need to analyze the 20, 60, 500 and 1000.


Note that if the number can differ between runs (but is constant for any given dataset) just turn my "40" diagram constant (lower left of code) into a control and set it according to the requirements of the set to be analyzed.

 

My code also assumes that the number of array elements is divisible by this number, but you can always add verification if desired.

0 Kudos
Message 4 of 4
(1,082 Views)