Finding all combinations of multiple variables summing to 1
问题 I am trying to solve the equation x1 + x2 + x3 + .... + xn = 1 where the values of all xi are restricted to [0, 0.1, 0.2, ..., 0.9, 1] . Currently, I am solving the problem by first generating an n-dimensional array mat , where at each element location the value is the sum of the axis values, which vary in axisValues = 0:0.1:1 : mat(i,j,k,...,q) = axisValues(i) + axisValues(j) + ... + axisValues(q). Then I search for all entries of the resulting array that are equal to one. The code (shown