Drawing a hyperboloid with polar coordinates
8 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Szabolcs Simon-Guth
el 5 de Nov. de 2021
Comentada: Mathieu NOE
el 8 de Nov. de 2021
Hi all!
I have received the following problem to solve:
Draw the surface of the hyperboloid with the equation:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/790709/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/790714/image.png)
Also, the polar coordinates for x and y must be used, i.e.:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/790719/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/790724/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/790729/image.png)
I have converted the equation of the hyperboloid so that it became: ![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/790734/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/790734/image.png)
I could then express z as: ![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/790739/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/790739/image.png)
I have the following code so far:
r = linspace(0,1,21);
a = linspace(0,2*pi,63);
[R,A] = meshgrid(r,a);
X = R.*cos(a);
Y = R.*sin(a);
Z = square((R.^2)-1);
surf(X,Y,Z);
axis equal
However, when ever I run the program I get a cylinder instead. I think the problem might be that the values of z should be between -3 and 3, however I do not know how to express this in the code. I would appricate any help that I get. Thank you for everyone in advance!
0 comentarios
Respuesta aceptada
Mathieu NOE
el 5 de Nov. de 2021
hello
you have to start from z and then compute r and not vice versa
also square root function is sqrt and not square
z = linspace(-3,3,21);
a = linspace(0,2*pi,63);
[Z,A] = meshgrid(z,a);
R = sqrt((Z.^2)+1);
X = R.*cos(A);
Y = R.*sin(A);
surf(X,Y,Z);
axis equal
2 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Surface and Mesh Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!