MATLAB: I get a warning in parfor (line 4) which might be unnecessary. Can I ignore it

MATLABparfor

A = linspace(1,4,4);
parfor i = 1:3
B = A(i)
C = A(i+1)
end

Best Answer

That warning is telling you that A is a broadcast variable. As such, the whole value of A is sent to each worker. This will function perfectly correctly, but it incurs more data transfer than would be the case if A was sliced.
In this case, you could try offsetting the array A by one element so that you have two sliced inputs:
A = linspace(1,4,4);
Aoffset = A(2:end);
parfor i = 1:3
B = A(i);
C = Aoffset(i);
end
I would try measuring the execution time to see if it's worth the bother.