how to write this code to generate what i want

2 visualizaciones (últimos 30 días)
Alexandra-Anamaria
Alexandra-Anamaria el 20 de Mzo. de 2025
Editada: Voss el 25 de Mzo. de 2025
Hi! I'm trying to write a code in mesh to ilustrate some a surface that in determined by the ecuation:
x,y,z are all coordonates on the axis. the surface should look like this:
but i can't get it to look the same. My code is:
clear all; close all; clc;
xmin=-pi;xmax=pi;nx=50;
x=linspace(xmin,xmax,nx);
ymin=-pi;ymax=pi;ny=50;
y=linspace(ymin,ymax,ny);
[X,Y]=meshgrid(x,y);
alfa=59*pi/180;
Z=sqrt(X.^2./tan(alfa)^2)+sqrt(Y.^2./tan(alfa)^2);
figure
mesh(X,Y,Z);
axis equal
can anyone please help me?

Respuesta aceptada

Voss
Voss el 20 de Mzo. de 2025
clear all; close all; clc;
xmin=-pi;xmax=pi;nx=50;
x=linspace(xmin,xmax,nx);
ymin=-pi;ymax=pi;ny=50;
y=linspace(ymin,ymax,ny);
[X,Y]=meshgrid(x,y);
alfa=59*pi/180;
% Z=sqrt(X.^2./tan(alfa)^2)+sqrt(Y.^2./tan(alfa)^2);
Z=sqrt((X.^2+Y.^2)./tan(alfa)^2);
figure
mesh(X,Y,Z);
hold on
mesh(X,Y,-Z);
axis equal
  3 comentarios
Alexandra-Anamaria
Alexandra-Anamaria el 20 de Mzo. de 2025
Thanl you! You helped me a lot!
Voss
Voss el 20 de Mzo. de 2025
Editada: Voss el 25 de Mzo. de 2025
You're welcome! Any questions, let me know. Thanks!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Startup and Shutdown en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by