-1

I have an issue where I have my data formatted such that I have n data points in the Z axis, and every Z data point has m corresponding x & y points. I essentially want to have n 2D m-point plots, but merged into one surface.

My data takes the following form:

z = [0 1 2 3]

data(:, :, 1) = [0 1 2; 2 2 2] (the first row corresponds to the x points, second to the y; the page (the 1) corresponds to the respective z point at which I am plotting said x and y points)

So essentially, at z(i), I would like to have data(:, :, i) plotted. Then finally all merged together into one surface. How would I accomplish this?

An example that might help imagine the situation is if data(:, :, i) for all i was uniform, like the above sample, then a cube surface (of volume 12) would be drawn.

IKavanagh
  • 6,089
  • 11
  • 42
  • 47
  • 1
    A little bit of code in-context would really help to clarify your question. Thanks! – Justin Fletcher Jul 16 '14 at 00:52
  • If you can show some data and maybe an example image of what you're expecting the output to look like, that would also help. I'm having trouble visualizing this – rayryeng Jul 16 '14 at 00:53

1 Answers1

0

So essentially, at z(i), I would like to have data(:, :, i) plotted. Then finally all merged together into one surface. How would I accomplish this?

Use scatter3 to plot 3-D scatter plot, for every points with a set of x,y,z value.

Alternatively, use plot3 to make 3-D line plot. Be careful with the argument formats.

You can use code like

for ii = 1:length(z)
    x = data(1, :, ii);
    y = data(2, :, ii);
    scatter3(x, y, z*ones(1, length(x));
end

Finally, rotate your angle of view using view([0,0,-1]) to the direction facing the z axis. By this, all layers of different z values are squeezed into one layer.

If you really mean you want to ignore the z-values, but only want to see an overlayed plot of all the points,

for ii = 1:length(z)
    x = data(1, :, ii);
    y = data(2, :, ii);
    scatter(x, y);
end

An example that might help imagine the situation is if data(:, :, i) for all i was uniform, like the above sample, then a cube surface (of volume 12) would be drawn.

As @rayryeng commented, I found this difficult to imagine. What do you mean by "a cube surface of volume 12"? This part looks different than descriptions above it.

Yvon
  • 2,903
  • 1
  • 14
  • 36