MATLAB: How to visualize points and planes in 3-dimensions using MATLAB

3-dMATLABplanespointsvisualize

How can I visualize points and planes in 3-dimensions using MATLAB?
I want to select 3 different points from a set of data in order to create a reference plane. Then, I want to visualise the positioning of the remaining points versus the reference plane using 3-D graphics. How can I do this?

Best Answer

Assume you have 3 vectors "x", "y", and "z" containing the components of a set of data. Further assume the plane is defined by the first 3 elements of these vectors. Then, the plane can be plotted using:
patch(x(1:3),y(1:3),z(1:3),'r')
In order to visualize this plane in 3-D, click the Rotate3D button at the top of the figure, and click and drag on the axes to rotate.
In addition, in order to plot the other points relative to the plane, use the following code:
hold on
plot3(x(4:end),y(4:end),z(4:end),'x')
Related Question