Mesh plot of the function sqrt(y-x^2)
Mostrar comentarios más antiguos
I want to plot the function
The function is defined for
. With
The function is defined for
. With f = @(x,y)sqrt(y-x.^2);
fmesh(f,[-3 3 0 9])
I get a mesh plot of the function in the rectangle [-3,3]X[0,9]. I want to plot the function using meshgrid. The following code results to complex values error message.
x = -3:1:3
y = 0:1:9
[X, Y] = meshgrid(x,y)
Z = sqrt(Y-X.^2)
mesh(X,Y,Z)
The problem is that Z is evaluated for not suitable pairs of (X,Y). What am I doing wrong?
Respuesta aceptada
Más respuestas (1)
Bruno Luong
el 6 de Abr. de 2021
Here is the surface in meshgrid form
s = -1:0.01:1;
y = 0:0.1:9;
[S, Y] = meshgrid(s,y);
X = S.*sqrt(Y);
Z = sqrt(max(Y-X.^2,0));
figure
mesh(X,Y,Z)

Categorías
Más información sobre Line Plots en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

