MATLAB: How to join two set of points using scatter command

colormaplineMATLABscatter

I want to join two set of points with a line. Each set should be attached by a line. There should be a color associated with each line.

Best Answer

x1=1:10; y1=1:10;
new_x1 = x1;
new_y1 = y1*2;
cmap = colormap(jet(length(x1)));
figure(1);
scatter(x1,y1,[],cmap,'Marker','d');
hold on;
scatter(new_x1,new_y1,[],cmap,'Marker','*');
hold off;
for i = 1:length(x1)
line([x1(i),y1(i)],[new_x1(i),new_y1(i)],'Color',cmap(i,:));
end
Related Question