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
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With