Skip to main content
deleted 17 characters in body
Source Link
march
  • 24.2k
  • 2
  • 46
  • 102

If you know the lengths Length@grid1 == 6, Length@grid2 == 6, Length@grid3 == 5, then you can take advantage of the structure of Tuples to brute force this:

grid1 = {0.1, 0.2, 0.2, 0.3, 0.4, 0.5};
grid2 = {0.2, 0.3, 0.7, 0.8, 1.1, 1.2};
grid3 = {0.17, 0.25, 0.35, 0.35, 0.4};
tuples = Join[Tuples[{grid1, grid2, grid3}],RandomReal[{1, 2}, {6*6*5, 1}],2];

tuples[[;; ;; (6*6*5)/Length@grid1Length@grid2 Length@grid3, 1]]
tuples[[;; ((6*6*5)/Length@grid1)Length@grid2 ;;Length@grid3 ((6*6*5)/(Length@grid1;; Length@grid2))Length@grid3, 2]]
tuples[[;; Length@grid3, 3]]

will result in the three grid lists.

If you know the lengths Length@grid1 == 6, Length@grid2 == 6, Length@grid3 == 5, then you can take advantage of the structure of Tuples to brute force this:

grid1 = {0.1, 0.2, 0.2, 0.3, 0.4, 0.5};
grid2 = {0.2, 0.3, 0.7, 0.8, 1.1, 1.2};
grid3 = {0.17, 0.25, 0.35, 0.35, 0.4};
tuples = Join[Tuples[{grid1, grid2, grid3}],RandomReal[{1, 2}, {6*6*5, 1}],2];

tuples[[;; ;; (6*6*5)/Length@grid1, 1]]
tuples[[;; ((6*6*5)/Length@grid1) ;; ((6*6*5)/(Length@grid1 Length@grid2)), 2]]
tuples[[;; Length@grid3, 3]]

will result in the three grid lists.

If you know the lengths Length@grid1 == 6, Length@grid2 == 6, Length@grid3 == 5, then you can take advantage of the structure of Tuples to brute force this:

grid1 = {0.1, 0.2, 0.2, 0.3, 0.4, 0.5};
grid2 = {0.2, 0.3, 0.7, 0.8, 1.1, 1.2};
grid3 = {0.17, 0.25, 0.35, 0.35, 0.4};
tuples = Join[Tuples[{grid1, grid2, grid3}],RandomReal[{1, 2}, {6*6*5, 1}],2];

tuples[[;; ;; Length@grid2 Length@grid3, 1]]
tuples[[;; Length@grid2 Length@grid3 ;; Length@grid3, 2]]
tuples[[;; Length@grid3, 3]]

will result in the three grid lists.

Source Link
march
  • 24.2k
  • 2
  • 46
  • 102

If you know the lengths Length@grid1 == 6, Length@grid2 == 6, Length@grid3 == 5, then you can take advantage of the structure of Tuples to brute force this:

grid1 = {0.1, 0.2, 0.2, 0.3, 0.4, 0.5};
grid2 = {0.2, 0.3, 0.7, 0.8, 1.1, 1.2};
grid3 = {0.17, 0.25, 0.35, 0.35, 0.4};
tuples = Join[Tuples[{grid1, grid2, grid3}],RandomReal[{1, 2}, {6*6*5, 1}],2];

tuples[[;; ;; (6*6*5)/Length@grid1, 1]]
tuples[[;; ((6*6*5)/Length@grid1) ;; ((6*6*5)/(Length@grid1 Length@grid2)), 2]]
tuples[[;; Length@grid3, 3]]

will result in the three grid lists.