How can i graph these equations?
Afficher commentaires plus anciens
How can i graph these two equations in Matlab? Below is the image:


I tried myself to plot them but the error is: "X,Y,Z,C can't be complex"
%Ecuación: x^2 + y^2 - z^2 - 4 = 0
x = 0:2:6;
y = 0:1:6;
[X,Y] = meshgrid(x,y);
Z = sqrt(X.^2 + Y.^2 - 4);
surf(X,Y,Z)
%Second one
x = 0:2:6;
y = 0:1:6;
[X,Y] = meshgrid(x,y);
Z = 1/2*(sqrt(X.^2 + Y.^2 - 8));
surf(X,Y,Z)
Réponses (2)
John D'Errico
le 15 Mar 2022
Modifié(e) : John D'Errico
le 15 Mar 2022
None of the solutions you tried are correct, because they try to treat these functions as single valued relations. That is not the case. They are better described as implicit functions, so fimplicit3 is correct.
fimplicit3(@(x,y,z) x.^2 + y.^2 - z.^2 - 4,[-4 4 -4 4 -4 4])
axis equal
fimplicit3(@(x,y,z) x.^2 + y + 4*z.^2 - 8,[-4 4 -4 4 -4 4])
Note that the viewpoint is different for the latter plot. It seems sort of a strange perspective as shown in your plot. But this latter figure can be interpreted as a simple paraboloid, though not a rotationally symmetric one, of the form
y = 8 - x^2 - 4*z^2
So still a simple conic form where the axes are rotated from what you might normally expect.
Catégories
En savoir plus sur 2-D and 3-D Plots dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

