I need to plot a lot of unconnected lines in MATLAB. This code will do it using a for loop:
x = 1:5;
y = 10:-2:2;
figure;
hold on;
for ii = 1:5
plot([0,x(ii)],[0,y(ii)],'b-');
end
Is it possible to do the same thing without using a for loop?
Use case: I am trying to visualize a tree and there are many lines to be drawn. I would like to precalculate the end points of all the lines and call plot or equivalent once. This is what I am doing with scatter to show the nodes of the tree.