LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

An array containing a factorial arrangement of numbers?

I’m a beginner with LabView and trying to figure out how to generate an array that contains a factorial arrangement of numbers.  I'm currently using nested loops where each row contains the value of each loop for that iteration.

 

I’ve tried initializing an array and then passing that initialized array through shift registers to the inner loop, and then wiring to a Replace Array Subset.  However, I’m not sure how to handle the indexing.  For instance, if there are 4 loops, each set to N=5, this would be a total of 625 rows.   The first column and first five rows (inner loop) would be 0, 1, 2, 3, 4.  This pattern would repeat 125 times in the first column.  Likewise, the outer array (fourth column) would result in 125 0s, then 125 1s, 125 2s, 125 3s, and 125 4s.

 

Any suggestions on what I'm missing and/or the approach I should be using?

 

Randy

0 Kudos
Message 1 of 9
(4,340 Views)
Hi RPN,

I am confused on two fronts. One I am not sure exactly what your trying to do. Are you trying to create an array of 0!,1!,2!,3! ... ? Secondly I am not sure from your description what you are doing?? Could you post the VI's or at least an image of the your diagram.

BTW there is a factorial.vi in I believe in both the pro and full (ie not in the base) version of Labview if you have that version?

Cheer,

--Russ
0 Kudos
Message 2 of 9
(4,334 Views)
I guess I don't understand what you mean by a "factorial arrangement of numbers". You are talking about rowns and columns, thus you probably have a 2D array.
 
Could you just give a real example of the desired output array, your description is not clear at all. Thanks! 🙂
0 Kudos
Message 3 of 9
(4,332 Views)

Thanks for the feedback.  I attached an Excel file containing the type of 2-D array I am trying to produce in LabView.  The information in the array relates to the factorial arrangement of treatments in an experimental design.  This particular example would contain 4 factors with each factor having 5 levels, resulting in 5x5x5x5 or 625 treatment combinations.  I’m trying to generate these treatment combinations.  The result will be a 2-D array where each row contains the level of each of the factors for that treatment combination.  For example, a row that contains 3-2-0-4 would be the treatment where factor 1 is at level 3, factor 2 is at level 2, factor 3 is at level 0, and factor 4 is at level 4.  A factor would be something like “Temperature.”   Then, for the factor “Temperature” the levels would be five different temperatures.  The other factors would likewise have 5 levels.  The resulting experiment would be every permutation of these 4 factors at 5 levels each.

 

I have been trying to use 4 nested loops to build this 2D array.  I thought I could record the value of each of the 4 loops after each iteration of the inner loop to generate the table shown in the Excel file.  Each column represents a factor and each row one loop iteration.

 

I completed the two beginner courses in LabView and this is the first project I have set myself to.

0 Kudos
Message 4 of 9
(4,319 Views)
OK, that's easy! 🙂
 
Here is one possibility (LabVIEW 7.0).
 

Message Edited by altenbach on 05-20-2006 09:53 AM

Download All
Message 5 of 9
(4,310 Views)

altenbach,

 

Your solution is Fantastic!  I was not even aware of the Quotient & Remainder function.  However, now I’m just curious to understand how a nested loop approach could be used to solve this type of problem.

 

RPN

0 Kudos
Message 6 of 9
(4,292 Views)
Here a nested loop solution. While it is is possible to calculate the index from the four iteration terminals, it is much easier to keep the index in a shift register and just increment the index after each replace operation.
 

Message Edited by altenbach on 05-20-2006 12:20 PM

Message 7 of 9
(4,291 Views)
The simplest "nested loop" approach is probably the following. 😄
 

Message Edited by altenbach on 05-20-2006 12:39 PM

Message 8 of 9
(4,287 Views)

altenbach,

 

This is great.  I really appreciate you providing these different options.  Apart from solving this specific problem, being able to compare and contrast them is extremely helpful to me as I learn LabView.

 

Best regards,

 

Randy

0 Kudos
Message 9 of 9
(4,268 Views)