I have been solving a problem using a parfor loop. However it has come to my attention that occasionally a large number of serial entries do not in fact have to be run, and I suspect that it reduces the advantage of the parfor loop, relative to a normal for-loop, whenever it has to deal with lots of "non-entries". As an example here is an illustration of a hypothetical situation, and process, which needs to be solved.
As you can see, 5 out of the 11 entries do not need to be run and so the parfor skips those accordingly (for the actual case the ratio is often more like 1/10 which is why I am exploring alternative solutions). However I wanted to explore a quick solution which would make the parfor loop inherently only evaluate real entries. My problematic code is shown here:
Matlab doesn't allow this. Veterans will likely look at this and go "obviously this is not possible" but I don't understand why, and more importantly, I don't understand how I might otherwise make a similar simple workaround (i.e.: not rebuild the entire actual process within the parfor loop) that would only evaluate the right numbers.
Can anyone help me out?
Thanks in advance!