Function like "surf", but without interpolation?

7 visualizzazioni (ultimi 30 giorni)
Peter Fraser
Peter Fraser il 4 Feb 2017
Commentato: Peter Fraser il 6 Feb 2017
I want to take a 16 x 16 array of data, and present it in 3D as an assembly of 16 x 16 cuboids, each having size "1" in the x and y directions, and a height proportional to the z value. "surf" almost does this, but it performs bilinear interpolation on the z values, and I want zeroth order hold. Also, "surf" would give a 15x15 surface, but I want a 16x16. I looked at some of the 3D bar charts but they don't seem to do what I want. Is there a function or option that I'm missing.
Thanks
  3 Commenti
Peter Fraser
Peter Fraser il 6 Feb 2017
Yes. The array that I want to plot represents an 2D array of pressure sensors. I want to display these as a 3D surface, with the height representing pressure, and the x and y axes correctly labeled. I then want to "hold" the graphic, and add more functions using the physically correct axes. I can do this fine with surf, but surf has bilinear interpolation, and a size of n-1 x n-1, neither of which I want.
I can get a display that looks fine using bar3, but I can't work out how to define x and y so that I can annotate it with additional functions of the (physically correct) x and y.
This code gives me the look that I want:
height = max(p_seq1(:));
for frame = 1:size(p_seq1, 3)
b = bar3(flip(p_seq1(:,:,frame)), 1.0);
axis([-inf inf -inf inf 0 1.1 * height]);
for k = 1:length(b)
zdata = b(k).ZData;
b(k).CData = zdata;
b(k).FaceColor = 'interp';
end
drawnow();
end
where p_seq1 is a 16 x 16 x 300 pressure sequence.
Perhaps I could label the axes so that they resemble the axes that I actually want, then inversely scale the annotation functions so that they map to the axes of bar3. That seems a bit complicated and messy though.
Thanks
Peter Fraser
Peter Fraser il 6 Feb 2017
To be clear, bar3 seems to allow me to do what I want in the x direction, but not the y.

Accedi per commentare.

Risposte (0)

Categorie

Scopri di più su Discrete Data Plots in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by