LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Create specific array based on variable test cases

Solved!
Go to solution

Hello,

I am extracting data from a very large excel spreadsheet.  Each row of the spreadsheet contains various amounts of test conditions in each cell of that specific row.  I have included a simplified version, where the different test condition has been separated out in each state of the state machine.

 

IN the attached case, there are 3 conditions for Test 1, 2 conditions for Test 2, 0 conditions for Test 3 and then 2 conditions for Test 4.  We must end up with an array that is 3 x 2 x 2 (12) rows. I would like to generate an array such that we vary the last column with different test conditions while keeping the left test conditions fixed.  After the last column test conditions are done, we then change the test condition in the adjacent left column...Test case 3 (in this case it will be Test case 2 as there are no conditions in Test case 3).  These iterations will be repeated until we end up with the array as shown in the table below:

 

2018-07-17_11-35-21.png

 

Thanks,

hiNi

Download All
0 Kudos
Message 1 of 7
(2,930 Views)

Use nested For Loops. 

 

Example_VI

Message 2 of 7
(2,909 Views)

Hello,

 

Thanks for your response.  I implemented your suggestion into the updated program.

 

However, if an extra test is added I will have to modify the for loops.  Is it possible to make the program more dynamic so that a for loop will not have to be added each time a new test array is added?

Download All
0 Kudos
Message 3 of 7
(2,894 Views)

Can this be made into another state machine format where as the number of tests are changed, the for loops can be changed accordingly?

 

This is what the for loop looks like...it may increase!

 

2018-07-18_11-10-05.png

0 Kudos
Message 4 of 7
(2,872 Views)

Here is a tip for you.  All those constants you have wired into the Index Arrays .....  you don't need them.  You automatically get 0, 1, 2, 3, .....

 

For a programmatic way to build the combinations where the number of tests is variable, I'd work with what you had going on in message 3.  With the following changes.

 

1.  Don't hard code a statemachine with test 1, test 2, test 3, test 4 .....

2.  Create an array where each element is the number of variations for each test.  So a 1-D array of 3, 4, 1, 2  means 4 different tests with 3 variations of 1, 4, of 2, 1 of test 3,  2 of test 4.  Now if you want a 5th test, you add another element.

3.  For the names of each test, create an array like you have in each "test X" case.  Build it into a cluster.  Build each cluster in an array.  Each element of that array represents one of the tests.  The cluster holds the array that gives the name for each variation of that test.  You basically want a 2-D array of strings, but because arrays can't be ragged, (i.e. you can't have row 1 be 3 elements and row 2 be 5 elements), the cluster gives you a way to work around that.

4.  Work out the logic in pseudo code for how to iterate with a single while loop.  Keep a shift register with the current index for each test.  Add 1 for test N test.  When you get to the last variation for that test, reset it back to one and increment the index for the for the test N-1.  When N-1 reaches the end, reset that back to 1 and increment test N-2.  When test #1 reaches the end, end the while loop.

 

 

Message 5 of 7
(2,865 Views)

Hello,

 

Thanks for your suggestion.  I have placed the tests in a cluster as per your recommendation (I left the case structures for now).  I am getting stuck in generating the array now for the tests.  Can you offer some more guidance as to how to generate the array list as shown in the original question? 

 

Thank you!

Download All
0 Kudos
Message 6 of 7
(2,857 Views)
Solution
Accepted by hiNI

Here's what I was talking about in my previous message.

Message 7 of 7
(2,836 Views)