Since you want to update the plot keeping the old data intact, add a pause after the plot and 'hold on' after the first plot. a sample code is provided for your reference.
figure; title('Plot loops');
A = rand(1,10);
B = rand(1,10);
N = length(A);
for idx=1:N
plot(A(1:idx),B(1:idx), '*-');
legend(['test' int2str(idx)]);
hold on
pause(2)
end
hold off