0
votes

I'm trying to plot a 2 dimensional signal on a specific plane in a 3d model. I have the matrix:

xyzp (nx3)

that contains all the points which are closest to the plane (e.g. when the plane is in the z direction, all the z coordinates are fairly similar). and I have a vector:

signal (nx1)

that contains a value for each point in xyzp. when I use: "surf([xyzp(:,[1,2]),signal)" or "mesh([xyzp(:,[1,2]),signal])" The plot I get doesn't look at all like the intersection of the plane with the model from any angle (I expected "view(2)" to show the signal in the Z direction), so I assume I didn't use the plot function correctly.

Can anyone show me an example? For instance - A circle on an xy plane with some random signal indicated by color

1
Does xyzp just contain a list of x-y-z coordinates that correspond per row to the values in signal? Also do the points form an ordered grid or are they arbitrarily placed?Dan
They are arbitrarily placed, and yes, they correspond per row to the values in the signal. Since they are pretty much on the same plane (not exactly but I don't care about the mild differences) I want a 2D plot of the points with the colors specifying the signal values.AmitG
...so you're happy to drop the z data? I think you should look at interpolating your data so that it falls on a regular grid and then you can just use surf. Try griddata for the interpolationDan
The z data is fairly insignificant because the points were derived from an algorithm which takes the closest points to an xy plane (it's actually an optional choice in a GUI to chose between xy, xz and yz and the axis is chosen respectively). The differences between the different z values are negligible and I wanted a view of the 2-dimensional cross section.AmitG

1 Answers

0
votes

surf and mesh can be used when the points form a rectangular grid on the xy plane.

In the general case (points are arbitrarily placed), you can use scatter3. For purposes of illustration, consider the following example xyzp and signal:

[x y] = ndgrid(-1:.01:1);
x = x+.3*y; %// example values which do not form a rectangular grid
z = x+y; %// example z as a function of x, y
xyzp = [x(:) y(:) z(:)];
signal = z(:)+x(:)-y(:); %// example values

Then

scatter3(xyzp(:,1), xyzp(:,2), xyzp(:,3), 1, signal, '.');

produces the following figure.

enter image description here

Since scatter3 plots each point separately, the picture is not as smooth as it would be with surf. But this seems hard to improve if the coordinates do not a have any "structure" (as surf requires) .