06-16-2019 01:33 AM
Hello everyone,
my problem is I want to make all the permutations of 2D array
Example(input 2D array)
Array= [1, 2 , 3;
4, 5, 6;
7, 8 , 9]
The result should be
[1,4,7;1,4,8;1,4,9;1,5,7;1,5,8;1,5,9;1,6,7;1,6,8;1,6,9;2,4,7;2,4,8;2,4,9;2,5,7;2,5,8;2,5,9;2,6,7;2,6,8;2,6,9;3,4,7;3,4,8;3,4,9;3,5,7;3,5,8;3,5,9;3,6,7;3,6,8;3,6,9]
The problem also is the 3*3 array is changing according to some measurement, so the array length is changing so according to my case I am having 6R*40C array, when the measurments change it can be 7*40 array or 8*40.
What I mean is I want a very generic software that can be applied to any 2D array length.
P.S
you need to notice that the software will produce row by row because if you try to calculate the whole array when it comes my case (in put array 6*40) the output array will be 6*1600 which will make the software stop excution regarding to the memory allocation.
so giving me row by row result in such way
1st iteration gives(1D array) >>1,4,7; (then I apply the result on my software till it fits the condition if it doesn't it needs to go for the 2nd loop)
2nd iteration gives(1D array)>> 1,4,9;(then I apply the result on my software till it fits the condition if it doesn't it needs to go for the 3rd loop)
.... so on.
Solved! Go to Solution.
06-16-2019 11:45 AM
It is not clear how you define "permutations" and how it relates to rows and columns. It seems like the number of columns in the output is equal to the number of rows in the input.
I don't think you are using the right word here.
To make our life easier, please attach a simple VI with your example array values in a control and the desired output in an indicator. Make all values the default before saving.
06-16-2019 12:52 PM
@YoussefAliSabri wrote:you need to notice that the software will produce row by row because if you try to calculate the whole array when it comes my case (in put array 6*40) the output array will be 6*1600 which will make the software stop excution regarding to the memory allocation.
so giving me row by row result in such way1st iteration gives(1D array) >>1,4,7; (then I apply the result on my software till it fits the condition if it doesn't it needs to go for the 2nd loop)
2nd iteration gives(1D array)>> 1,4,9;(then I apply the result on my software till it fits the condition if it doesn't it needs to go for the 3rd loop)
.... so on.
Well, you just need to generate them one-by-one, e.g. as follows. (You would remove the 2D output and just process one row at a time until the condition is met.
(Once you tell us your LabVIEW version, I'll attach the VI)
(More general comment: it is not recommended to give an example with a square array if the array is not necessarily square at all times. It is easy to make simple coding mistakes and we won't notice if width and height are the same size during testing).
06-16-2019 03:57 PM
It took me a few reads to "get" the nature of this (what I presume is a) Homework Problem -- I was puzzled how "arrays" fit into this, but I came up with an alternate formulation that I think makes more sense and also makes a more "interesting" problem:
In your formulation, M was a factor of N, so all the bags contained the same number of elements. This lends itself to using a 2D Array to represent the bags (each Row is a bag, and the columns hold the Bag Content), but that's just a representation "feature" that (in my opinion) "gets in the way" of thinking about the Problem and Its Solution.
I hope the answer to the Easy Question is obvious to you ...
Bob Schor
06-17-2019 01:15 AM - edited 06-17-2019 01:18 AM
WOW
just a wow !
Yeah I know this is not the right word and exact word for using permutation. BUT what is permutation(It's a combination when order matters) it's just a general definition to it. so I want was the all combination with respect possibilities(so I called it permutation).
I am using LabVIEW 2014 (32Bit)
thank you for your help.
I just want to know the VI name which in left down corner under the 1st for loop in the left of the whole VI.
Thank you so much!
06-17-2019 01:23 AM
It took me a few reads to "get" the nature of this (what I presume is a) Homework Problem!
I am not an English native.
I am coming here for help on my masters and this help is very TINY step on my whole masters(Practical and Theoretical) content.
and let me tell you I did it.the day I posted the question but it was not as good as the one helped me above your comment.
Have a nice day!
06-17-2019 01:52 AM
@YoussefAliSabri wrote:
I just want to know the VI name which in left down corner under the 1st for loop in the left of the whole VI.
See attached LabVIEW 2014 version. Please check for correct operations and modify as needed..