Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Matlab plot multiple 3d lines

Tags:

plot

matlab

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

like image 655
user2824393 Avatar asked Dec 05 '13 19:12

user2824393


People also ask

Can we have multiple 3d plot in Matlab?

Can we have multiple 3d plots in MATLAB? Explanation: The plot3() function is a pre-defined function in MATLAB. So, it will allow the use to generate multiple 3d plots.

How do you plot a 3 D graph in Matlab?

plot3( X , Y , Z ) plots coordinates in 3-D space. To plot a set of coordinates connected by line segments, specify X , Y , and Z as vectors of the same length. To plot multiple sets of coordinates on the same set of axes, specify at least one of X , Y , or Z as a matrix and the others as vectors.


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.

like image 123
A. Donda Avatar answered Nov 15 '22 06:11

A. Donda