0

I need to loop over all the possible combinations of the different elements of a vector between lower and upper bounds.

NUMBEROFVARIABLES stores the total number of variables.

tlb < t < tub and o1b < o < oub

The elements t and o can vary in steps of tStep and oStep respectively.

The vector is: x = [t1, t2, t3, ... tn, o1, o2, o3, ... on]

For 1 < t < 10, 1.5 < o < 5, tStep = 1, oStep = 0.5 and NUMBEROFVARIABLES = 10 (divided equally/half-half between 't's and 'o's), the generated combination vectors should be something like:

x1 = [1, 1, 1, 1, 1, 1.5, 1.5, 1.5, 1.5, 1.5]
x2 = [1, 1, 1, 1, 1, 1.5, 1.5, 1.5, 1.5, 2.0]
x3 = [1, 1, 1, 1, 1, 1.5, 1.5, 1.5, 1.5, 2.5]
.
.
.
xi = [1, 1, 1, 1, 2, 5.0, 5.0, 5.0, 5.0, 5.0]
xii = [1, 1, 1, 1, 3, 5.0, 5.0, 5.0, 5.0, 5.0]
xiii = [1, 1, 1, 1, 4, 5.0, 5.0, 5.0, 5.0, 5.0]
.
.
.
xn = [10, 10, 10, 10, 10, 5.0, 5.0, 5.0, 5.0, 5.0]]

How do I loop over each parameter (like in the above example) and store the vectors xi in MATLAB?

Shivanand
  • 144
  • 1
  • 1
  • 13
  • I don't know what DOE is, but in newer versions of MATLAB calling a vectorized function you can do `vfun(tlb:tStep:tub, [olb:oStep:oub].');` – beaker Mar 28 '17 at 22:38
  • @beaker I have many different 't's and many different 'o's. The number of 't's and 'o's is stored in NUMBEROFVARIABLES – Shivanand Mar 28 '17 at 23:25
  • Then give a representative example of what you need. How are the variables themselves stored? Looping from `1:NUMBEROFVARIABLES` is trivial, so you're probably asking something more. It's not apparent what from your question. – beaker Mar 28 '17 at 23:41
  • @beaker Edited the question – Shivanand Mar 29 '17 at 01:00
  • 1
    You don't want `xj = [1, 1, 1, 1, 2, 1.5, 1.5, 1.5, 1.5, 1.5]`? You might start looking [here](http://stackoverflow.com/questions/21895335/generate-a-matrix-containing-all-combinations-of-elements-taken-from-n-vectors) for ideas. – beaker Mar 29 '17 at 14:36
  • @beaker The vector you mentioned is also included. I could not list out everything here. Hence the dots – Shivanand Mar 29 '17 at 16:16

0 Answers0