3D mesh/surf plot puzzle
3 views (last 30 days)
Show older comments
The following codes produces a 2D image and its corresponding 3D demonstration. However, the pixel in the 2D image as a square becomes a grid-point in the 3D image. That's why the 3D image has a sharp top, rather than a square cylinder. I'm wondering how I can display a 2D matrix in a 3D manner without such pixel->grid-point conversion? For example, I would like to see a square cylinder with a flat top in the 3D image, but not a triangle stuff.
img = zeros(5,5);
img(3,3) = 10;
subplot(121)
imagesc(img); axis image
subplot(122)
mesh(img)
% shading interp
colorbar
set(gcf, 'position', [2111 475 560 420])
axis tight
0 Comments
Accepted Answer
Chris McComb
on 24 Mar 2015
You should try using the bar3 function, as follows:
bar3(img, 1.0)
The 1.0 sets the width to unity, so that the bars are adjacent to one another. The only problem is that the coloring isn't done according to height. To recover the correct coloring, you can use an approach like what is used here .
0 Comments
More Answers (0)
See Also
Categories
Find more on Orange in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!