title: Most efficient way to draw a bunch of 3d lines in matlab
body: <p>I need to plot a list of 3d lines in matlab. What is the quickest way to do that?
  I am currently doing something like</p>
  
  <pre><code>%edges is a MX2 matrix, holding the list of edges
  %points are the vertices' coordinates
  hold on; %so all the lines will be saved
  for i=1:size(edges,1)
      a=edges(i,1); %get first point's index
      b=edges(i,2); %get second point's index
      p=[points(:,a) points(:,b)]; %construct a 3X2 matrix out of the 2 points
      plot3(p(1,:),p(2,:),p(3,:)); %plot a line
  end
  </code></pre>
  
  <p>But this is not only slow during the actual loop, but also at the end, the resulting plot is very slow and irresponsive when I try to, for instance, rotate it using the drag &amp; rotate tool.</p>
  
  <p>I know the same plot using opengl etc would run much faster...</p>