MATLAB: Plotting a 4d graph as a series of 3d slices

3d matrix3d plotsgraphMATLABmatrix manipulationslice

I am measuring the intensity of a set of power meter readings over a 3d space. I am currently running a scan of 50×50 points in the x and y directions at a given z point and recording the intensity at each step.
This works and i can plot a surf, or a pcolor fine.
What I want to do now is take a series of scans at different z points, I would like to display all of this data on a 3d graph displaying the pcolor (or something similar) graph for each z point as a plane.
I have been looking at the slice function but have not been able to get it to work.
Basically I have:
Xpoints = 50×50 double, Ypoints = 50×50 double, Readings = 50×50 double,
at point z1
and i will have a series of these at different z values.
Can somebody help me with formatting this data so that I can use slice with the full set of z values or have any suggestions about how I should do this?

Best Answer

I think you will want to use the surface command. The idea is that you can set the Z-data to a single number (well, really an appropriately sized array containing all the same value) so that it is flat, and then use the fourth input argument to surface that controls the color.
Here's a simple example:
% One data set
[x1, y1] = meshgrid(1:50);
reading1 = rand(50);
z1 = 1;
% Another data set
[x2, y2] = meshgrid(1:50);
reading2 = rand(50);
z2 = 2;
% Draw
surface(x1, y1, z1*ones(size(x1)), reading1);
surface(x2, y2, z2*ones(size(x2)), reading2);
view(3)
Related Question