MATLAB: How to make a matrix grow inside a parfor loop

growing matrixParallel Computing Toolboxparfor

Hi, i would like to do this in a parfor loop:
S=[];
for n=in:fin
[s,trueorfalse]=somefunction(someinput);
if trueorfalse
S=[S;s];
end
end
I cannot preallocate because i don't know how much big S will be. I tried some thing but nothing worked so far.
Hope you could help me.

Best Answer

You should be able to do this. For example, the following works correctly:
S = [];
parfor idx = 1:10
r = rand();
if r > 0.5
S = [S, r];
end
end
Related Question