How can i graph these equations?

1 visualización (últimos 30 días)
Antonio Rafaek Cedillo Rodríguez
Antonio Rafaek Cedillo Rodríguez el 14 de Mzo. de 2022
Editada: John D'Errico el 15 de Mzo. de 2022
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)

Respuestas (2)

Torsten
Torsten el 15 de Mzo. de 2022

John D'Errico
John D'Errico el 15 de Mzo. de 2022
Editada: John D'Errico el 15 de Mzo. de 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.

Categorías

Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by