Help me about sphere ?
Afficher commentaires plus anciens


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.
Réponses (1)
Mischa Kim
le 27 Mai 2014
Modifié(e) : Mischa Kim
le 27 Mai 2014
Nguyen, use instead
z = real(sqrt(1 - x.^2 - y.^2));
to retain the real part only.
3 commentaires
Nguyen Trong Nhan
le 27 Mai 2014
Modifié(e) : Nguyen Trong Nhan
le 27 Mai 2014
Mischa Kim
le 27 Mai 2014
Modifié(e) : Mischa Kim
le 27 Mai 2014
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
le 27 Mai 2014
Catégories
En savoir plus sur App Building dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!