why do I need to add eps ?

hello I want to ask why do I need to add the value eps to this code ?
x=-8:0.5:8;
y=x';
[xi,yi]=meshgrid(x,y);
r=sqrt(xi.^2+yi.^2)+eps;
z=sin(r)./r;
mesh(x,y,z,r)
becouse for some reason if I do not add eps i get a hole in the top, why is that ?

回答 (1 件)

Andrei Bobrov
Andrei Bobrov 2018 年 9 月 2 日
編集済み: Andrei Bobrov 2018 年 9 月 2 日

0 投票

To avoid the uncertainty of "0/0" situation when calculating z.
When x = 0 and y = 0.

1 件のコメント

tomer polsky
tomer polsky 2018 年 9 月 2 日
ohh ok thank you very much

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

カテゴリ

ヘルプ センター および File ExchangeElementary Math についてさらに検索

タグ

質問済み:

2018 年 9 月 2 日

コメント済み:

2018 年 9 月 2 日

Community Treasure Hunt

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

Start Hunting!

Translated by