3D mesh/surf plot puzzle

1 回表示 (過去 30 日間)
Kyle Wang
Kyle Wang 2015 年 3 月 24 日
回答済み: Chris McComb 2015 年 3 月 24 日
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

採用された回答

Chris McComb
Chris McComb 2015 年 3 月 24 日
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 件)

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by