Mesh Plot

I am attempting to plot the equation X^2 + 4*Y^2 < 1, using the mesh function. I currently have the code
[X,Y] = meshgrid(-1:.25:1);
Z = ((X.^2 + 4 * Y.^2) );
mesh(X,Y,Z)
However, this does not follow the requirement of Z < 1. How would I accomplish this?

Respuestas (1)

the cyclist
the cyclist el 2 de Ag. de 2011

0 votos

I don't understand why you expect Z to be less than 1, since your definition of Z clearly has a maximum of 5.
However if you only want to plot values of Z that are less than 1, then you could substitute "NaN" where Z>=1, like this:
Z(Z>1) = NaN
and then do your mesh plot.

8 comentarios

Sean de Wolski
Sean de Wolski el 2 de Ag. de 2011
z(z>=1)=nan
Tyler
Tyler el 2 de Ag. de 2011
Thank you both for you quick reply.
However, trying your suggestion, I do not receive the graph I am anticipating. Adding the Z(Z>1) = NaN (or Z(Z>1) = NaN) seems to cut off the plot at a size smaller than wanted. I am assuming to see a bowl-shaped plot, but with this added code it looks more like a banana.
Sean de Wolski
Sean de Wolski el 2 de Ag. de 2011
Perhaps you wanted
Z(Z>1) = 1;
so that it shows as one instead of blank?
the cyclist
the cyclist el 2 de Ag. de 2011
Well, the equation is what it is. Maybe if you plotted a finer mesh it would be better. Also, consider using the view() command to change the perspective.
Tyler
Tyler el 2 de Ag. de 2011
I am unfamiliar with the finger mesh, how would that help me? I understand that my original graph was correctly plotting the equation I have given it, but my desired equation of X^2 + 4*Y^2 < 1 does not appear to be a valid equation.
the cyclist
the cyclist el 2 de Ag. de 2011
Also, the "4" in your equation is definitely going to mean that the shape is not very symmetrical between X and Y. Is that 4 really supposed to be there?
the cyclist
the cyclist el 2 de Ag. de 2011
Sorry! I made a typo of "finger mesh" instead of "finer mesh". I corrected it.
Sean de Wolski
Sean de Wolski el 2 de Ag. de 2011
http://www.mathworks.com/matlabcentral/fileexchange/16728-fingerprint-application
finger meshing!

Iniciar sesión para comentar.

Productos

Etiquetas

Preguntada:

el 2 de Ag. de 2011

Community Treasure Hunt

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

Start Hunting!

Translated by