Mesh : Display only nonzero values

When I draw a 3D graph with a mesh, I only want to display non-zero values. What should I do?
Please help me!
Thank you.

 採用された回答

the cyclist
the cyclist 2021 年 2 月 5 日

2 投票

In this code, I take the first example from the documenation for mesh, and don't plot the negative values by setting them to NaN:
[X,Y] = meshgrid(-8:.5:8);
R = sqrt(X.^2 + Y.^2) + eps;
Z = sin(R)./R;
Z(Z<0) = nan; % Set negative values to NaN, so that they are not plotted
figure
mesh(X,Y,Z)
You should be able to do the equivalent thing, with
Z(Z==0) = nan;

1 件のコメント

Joon Choi
Joon Choi 2021 年 2 月 5 日
Wow!!
Thank you so much!!!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeDiscrete Data Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by