help with contour plot

Trying to plot.
The equation is:
A tip in polar coordinates:
And my code:
(The picture above is how it is supposed to look9

1 Kommentar

Walter Roberson
Walter Roberson am 29 Apr. 2020
Note that volunteers are seldom interested in typing in code from pictures of code. Make it easier for the volunteers by providing actual code.

Antworten (1)

Walter Roberson
Walter Roberson am 29 Apr. 2020

0 Stimmen

Your line with == computes whether each element of Z happens to have a particular and exact relationship to X and Y. Once it has done that computation of whether there is a match or not, your code then throws away that computation, having wasted time but otherwise not having done anything useful.
I would suggest to you,
Z2 = X.^2 + Y.^2 + 1;
surf(X, Y, Z2)

4 Kommentare

Hanna Sundling
Hanna Sundling am 29 Apr. 2020
I changed as you suggested but the biggest problem is that when I plot is that I only get this:
And not the full object, and I do not know why.
Walter Roberson
Walter Roberson am 29 Apr. 2020
Your sample diagram has negative Z values. Your suggested code of surf(X, Y, Z.^2) has only positive Z (unless Z includes values with purely imaginary components. You need to go back and decide whether using X, Y, Z^2 is correct surfing.
Hint: if P^2 = something, then it implies that P of both +sqrt(something) and -sqrt(something) are valid.
Hanna Sundling
Hanna Sundling am 29 Apr. 2020
I do not understand how I sholud change.
I tried writing Z1 = Z2.^2 an then surf(X,Y,Z1)
Walter Roberson
Walter Roberson am 29 Apr. 2020
surf() one thing. "hold on". surf() another thing that is mirror in Z.

Diese Frage ist geschlossen.

Tags

Gefragt:

am 29 Apr. 2020

Geschlossen:

am 20 Aug. 2021

Community Treasure Hunt

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

Start Hunting!

Translated by