Help me about sphere ?

1 回表示 (過去 30 日間)
Nguyen Trong Nhan
Nguyen Trong Nhan 2014 年 5 月 27 日
コメント済み: Nguyen Trong Nhan 2014 年 5 月 27 日
I have this code to draw haft of sphere x^2 + y^2 + z^2 = 1, z>0. but it have error. help me to fix it. thanks very much.

回答 (1 件)

Mischa Kim
Mischa Kim 2014 年 5 月 27 日
編集済み: Mischa Kim 2014 年 5 月 27 日
Nguyen, use instead
z = real(sqrt(1 - x.^2 - y.^2));
to retain the real part only.
  3 件のコメント
Mischa Kim
Mischa Kim 2014 年 5 月 27 日
編集済み: Mischa Kim 2014 年 5 月 27 日
In a perfect world, yes. However, in numerical computations zero is not always (exactly) equal to zero. Check out this answer for reference. If you remove the semi-colon from
z = sqrt(1 - x.^2 - y.^2)
you'll notice that there are small non-zero imaginary parts.
Nguyen Trong Nhan
Nguyen Trong Nhan 2014 年 5 月 27 日
ah Mischa Kim, could you explain me when I need to use the eval and double funtions in matlab ?

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

カテゴリ

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