Are you clearing the figure at the start of each iteration in your loop? I am not seeing the problem you are facing. I got the below output from the code pasted.
The only thing I changed is to take out the 'ax' from pie() call and added 'ax=gca' later.
TargetAP18pie=0; TargetAPQpie=30; TargetAP38pie=10; TargetAPHpie=0; TargetAPWOTpie=10;
h2 = pie([TargetAP18pie TargetAPQpie TargetAP38pie TargetAPHpie TargetAPWOTpie]);
newColors = [...
0.5020 0.5020 0.5020;
0.3020 0.7490 0.9294;
1.0000 0.4118 0.1608;
0.7725 0.5098 1.0000;
0.0510 0.8784 0.8784];
ax = gca;
ax.Colormap = newColors;
lgd=legend('1/8', '1/4', '3/8', '1/2','WOT');lgd.Location='bestoutside';
See that both TargetAP18pie and TargetAPHpie are still present in the legend but not on the pie chart. Also, the colors are applied in the same order as the variables.
Is this what you are looking for?