LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Possible index combinations in 2D array - more Math Question than LabView???

Hi All,
I accidently submitted the first post.. please disregard the previous one.
 
I am struggling with this problem. Please HELP!!!
 
I have an array of numbers:
Set1  50     62    73    82       91     96   100
Set2  43     78    146  186     230   255
Set3  0.25  2      6     12       20
Set4  5       50    500   2000  8000
Set5  5       50    500   2000  8000
 
I need to create all possible combinations for Set1 through Set5.
Example:
{50, 43, 0.25, 5, 5}
{50, 43, 0.25, 5, 50}
{50, 43, 0.25, 5, 500}
{50, 43, 0.25, 5, 2000}
{50, 43, 0.25, 5, 8000}
 
{50, 43, 0.25, 5, 5}
{50, 43, 0.25, 50, 5}
{50, 43, 0.25, 500, 5}
{50, 43, 0.25, 2000, 5}
{50, 43, 0.25, 8000, 5}
 
{50, 43, 0.25, 5, 5}
{50, 43, 2, 5, 5}
{50, 43, 6, 5, 5}
{50, 43, 12, 5, 5}
{50, 43, 20, 5, 5}

and so on....

I just can't figure out how to loop this through to go through all possible combinations of the 5 sets. :((

Looking forward to your suggestions and help.

Thanks,

Mim

Message Edited by Mim on 11-17-2005 11:26 AM

0 Kudos
Message 1 of 3
(2,932 Views)
You have to have 5 nested loops.
Let's call your COLUMNS A-E and your ROWS 0-4:

A0 B0 C0 D0 E0
A1 B1 C1 D1 E1
A2 B2 C2 D2 E2
A3 B3 C3 D3 E3
A4 B4 C4 D4 E5

Extract all the COLUMNS.

Take COLUMN A and autoindex it on the first (outside) loop:
For i = 0 to 4
Ax = A[i]
Pass Column B THROUGH the first FOR loop and autoindex it on the second loop:
For i = 0 to 4
Bx = B[i] // autoindexing will do this for you
Pass Column C THROUGH the first and second FOR loop and autoindex it on the third loop:
For i = 0 to 4
Cx = C[i] // autoindexing will do this for you
and so on:
For i = 0 to 4
Dx = D[i] // autoindexing will do this for you
For i = 0 to 4
Ex = E[i] // autoindexing will do this for you
Assemble Ax, Bx, Cx, Dx and Ex into a set and do with it what you want.





Just do five nested loops and remember to autoindex A on the outside loop, B on the 2nd, C on the 3rd, D on the 4th, and E on the inside loop.

I think you will get 5^5 combinations.

Message Edited by CoastalMaineBird on 11-17-2005 10:44 AM

Message Edited by CoastalMaineBird on 11-17-2005 10:45 AM

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


LinkedIn

Blog for (mostly LabVIEW) programmers: Tips And Tricks

Message 2 of 3
(2,929 Views)
Hi  CoastalMaineBird
 
It works wonderful! Thanks sooo much for helping me with this....
 
Mim.
0 Kudos
Message 3 of 3
(2,908 Views)