How to create discontinuous surfaces?

5 ビュー (過去 30 日間)
Sana Ahmed
Sana Ahmed 2019 年 8 月 8 日
回答済み: Jaswanth 2024 年 10 月 25 日
I am using the surf fucntion with an array that I have populated with heights for the surface. When the height in the array is zero I want the surface not to be drawn there instead of the surface being filled in at the 0 height.

回答 (1 件)

Jaswanth
Jaswanth 2024 年 10 月 25 日
Hi,
To create discontinuities in your surface plot using the ‘surf’ function, you can replace height values of ‘zero’ with ‘NaN’. This will prevent the surface from being drawn at those points, resulting in the desired gaps.
Assuming ‘z’ is your data array for heights, you can use the following line to introduce discontinuities:
% Replace zero values with NaN to create discontinuities
z(z == 0) = NaN;
I hope this is helpful!

カテゴリ

Help Center および File ExchangeLighting, Transparency, and Shading についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by