I understand that you want to save your animated plot as a video. The program can be modified as follows to save the plot:
outputVideo = VideoWriter(fullfile(pwd, 'plot_movie.avi')); % Create VideoWriter object
outputVideo.FrameRate = 20; % Set frame rate for corresponding pause duration
open(outputVideo)
for ci=1:n
addpoints(h1,xx1(ci),yy1(ci));
addpoints(h2,xx1(ci),yy2(ci));
pause(0.05);
drawnow
img = getframe % Obtain figure as movie frame
writeVideo(outputVideo, img); % Write image to video
end
close(outputVideo) % Close video file