I am trying to generate computations for a problem of the form N Choose K. The function is computational expensive, so I would like to use parallel computing. Using a preallocated array and sliced variables, originally my code looked like this:
A(x,y) = somefunction(x,y)
When I try to run I get the following error:
Error: When indexing the sliced variable 'A', the range of the for-loop variable 'y' must be a row vector of positive constant numbers or variables. For more information, see Parallel for Loops in MATLAB, "Nested for-Loops with Sliced Variables".
The problem is the y variable as it is not constant. To solve this issue, I changed the code to:
A(x,y) = somefunction(x,y)
Which it now works. However, it seems to me that having to run the check y > x so many times is very inefficient.
Would there be a better way?