I have the following:
[x,y] = meshgrid(-2:.2:2); z = x .* exp(-x.^2 - y.^2); surf(x,y,z)
and I am trying to get the following:
How do I graph it to exclude the mid section like that?

 Respuesta aceptada

Star Strider
Star Strider el 8 de Mzo. de 2018

0 votos

NaN is your friend here:
NOTE — You have to use two separate vectors in your meshgrid call to create this effect, not the single vector you have in the code you posted. One vector is the one in your code. You have to create the second one with the gap.

1 comentario

I used your code as you posted it to calculate the ‘z’ matrix:
[x,y] = meshgrid( ... );
z = x .* exp(-x.^2 - y.^2);
surf(x,y,z)
shading interp
The solution to the problem of create the figure is in giving meshgrid the correct vectors. One vector is continuous from -2 to +2, the other goes from -2 to +2, with a ‘gap’ value at the position in the vector where you want the discontinuity in the surface.
The essence of this homework assignment is for you to create the other vector.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre 2-D and 3-D Plots en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 8 de Mzo. de 2018

Comentada:

el 8 de Mzo. de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by