3-D surface plot for vectors x1,y1,z1,x​2,y2,z2...​.......xn,​yn,zn

I want to plot the vectors in 3 D surface.
I used plot3(x1,y1,z1,x2,y2,z2......xn,yn,zn) but I am getting lines in 3-D.
Can you please tell me how to plot like surface in 3 dimension for n vectors for 3 axes, i.e. x1,y1,z1,x2,y2,z2............xn,yn,zn.
Thanks.

 Accepted Answer

Plot a surface in 3 dimension for n vectors? Probably not. In general, the choice of surface would be ambiguous and thus arbitrary. The situation is not much different from the problem of constructing a surface from a point-cloud.
For example, let x1, y1 be a circle, and let x2, y2 be a circle in a parallel plane, "aligned" (i.e., the line connecting the centers of the two circles is normal to both planes.) What is the surface? Is it a cylinder? Maybe. But maybe the actual surface is two cones joined at the point half way between the two centers. Can you prove otherwise just given the vectors?

6 Comments

Hey Thanks for your reply,
I got so many lines and they are not forming any sphere,cube like.
If I will cover all the lines by sheet, the surface looks like non uniform rectangular sheet.
I want to know what function should I use in place of plot 3, so I will get surface.
Thanks
When all you have is the vectors, you cannot assume that two vectors that are adjacent in space are connected by something like an elastic surface. The "real" surface could pass through the vectors in any order, and could have any kind of behavior between the known vectors.
There is no Mathworks-provided function that can create a surface based only on vectors.
In order to create a surface, you will need to provide adjacency information.
For example, if all of the vectors are exactly the same length, and if (x1[1],y1[1]) is considered to be connected to (x2[1],y2[1]) and that is to be considered connected to (x3[1],y3[1]) and so on, the N'th point of a particular vector being considered to be connected to the (N-1)'st point and (N+1)'st point in the same vector and to the N'th point in the vector "before" and "after" -- if this is true, then in such a case you would have enough information to construct a triangular mesh and plot it with trimesh()
Yes all the vectors are of same length, but I tried trimesh in place of plot3, it is not working, Error Error in ==> trimesh at 104 h = patch('faces',trids,'vertices',[x(:) y(:) z(:)],'facevertexcdata',c(:),...
Any other function?
Did you construct the representation of the triangles that trimesh() requires for its input? trimesh() cannot simply be passed vectors (or even simple arrays): the connection matrix is crucial.
Sorry,but I tried to findout how to do with so many vetors in help, but I mnot getting how to construct the representation of the triangles that tirmesh() requires for its input
X = [x1(:); x2(:); x3(:); x4(:); ...; xn(:)];
Y = [y1(:); y2(:); y3(:); y4(:); ...; yn(:)];
Z = [z1(:); z2(:); z3(:); z4(:); ...; zn(:)];
NV = n; %number of vectors
VL = length(x1);
V = (1:((NV-1)*VL)-1).';
T1 = [V, V+1, V+VL];
Now, T1 will be a partial "tri" matrix built up like
|\|\|\
- - -
Except that T1 is a bit too large: it has the entries that correspond to using the top point in each vector as the lower-left corner and the bottom point in the next vector as if it were the upper-left corner. These entries must be removed from T1, which can be done by removing each (VL+1)'st row.
After that you need to construct T2, in very much the same pattern, except being the upper-right triangles, like
/|/|/|
- - -
and remove the extra rows in it.
Then T = [T1;T2] would be the "tri" representation, and x, y and z would be the coordinate vectors to use for the X, Y, Z arguments for trimesh()

Sign in to comment.

More Answers (0)

Products

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!