3d function domain problem

7 visualizaciones (últimos 30 días)
Nathan Shapiro
Nathan Shapiro el 3 de Oct. de 2020
Respondida: madhan ravi el 3 de Oct. de 2020
When graphing 3d surface functions, how do you limit the points generated by meshgrid to within the domain of the function? For example, in the function z = sqrt(9-x^2-4y^2), the domain is all (x,y) inside or on the ellipse x^2 + 4y^2 = 9. In the code below the best I could do was limit x1 and y1 so that x and y would always be within this ellipse, but I am still missing part of the function. Is there a way to create an elliptical (or other than rectangular) domain for the function?
clear
clc
r=100;
x1 = linspace(-2,2,r);
y2 = linspace(-1.5,1.5,r);
[x,y] = meshgrid(x1,y2);
z=sqrt(9-x.^2-4*y.^2);
figure
mesh(x,y,z)
xlabel('x');
ylabel('y');
zlabel('z');
grid on

Respuestas (1)

madhan ravi
madhan ravi el 3 de Oct. de 2020

Categorías

Más información sobre Surface and Mesh Plots en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by