Output variables in parfor loops must be either sliced outputs or reduction outputs. More info here in the doc. In this case, you need KB to be a "reduction" variable since each iteration of your loop computes an increment to that matrix. To fit in with the parfor rules, you cannot index a "reduction" variable, so you need to modify things a little to have each iteration compute a full-sized increment. Something a bit like this
parfor i = 1:nelem
% compute KB_final and index
KB_increment = zeros(sdof);
KB_increment(index,index) = KB_final;
% Use a reduction assignment into KB:
KB = KB + KB_increment;
end