3d function domain problem
7 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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
0 comentarios
Respuestas (1)
Ver también
Categorías
Más información sobre Surface and Mesh Plots en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!