Matlab plot multiple 3d lines

Viewed 14233

I have n pairs of points :

(x1,y1,z1) (u1,v1,w1) ,  
(x2,y2,z2) (u2,v2,w2) ,
....                  , 
(xn,y2,zn) (un,vn,wn) 

I want to plot 3d line for each pair. All lines in the same window (plot).

So I will have in total n lines .

How can I do this in Matlab ?

Thanks

1 Answers

Parag's answer is of course correct. However, you can also plot multiple lines with one call to plot3, if data are arranged correctly. For your example:

x = [0 , 3; -1, -5]';
y = [0 , 3; -1, -5]';
z = [0 , 3; -1, -5]';

plot3(x, y, z)

Specifically, plot3 (just as plot and line) produces one line for each column of its three (two) inputs.

Related