Need help using mesh and surf

1 visualización (últimos 30 días)
Shawn
Shawn el 22 de Feb. de 2014
Comentada: Shawn el 22 de Feb. de 2014
Im trying to generate a surface plot using the following variables,
-10<x<10
-10<y<10
t=sqrt(x^2 + y^2)
z=sin(t)/t
when i try to use the surf (or mesh) command it gives me an error saying that Z must be a matrix and not a scaler or vector. I've tried surf(x,y,z) and many other variations, but to no avail. Please help.

Respuesta aceptada

Mischa Kim
Mischa Kim el 22 de Feb. de 2014
Editada: Mischa Kim el 22 de Feb. de 2014
Shawn, use
[X,Y] = meshgrid(-10:0.5:10, -10:0.5:10);
t = sqrt(X.^2 + Y.^2);
Z = sin(t)./t;
surf(X,Y,Z)
  1 comentario
Shawn
Shawn el 22 de Feb. de 2014
Thank you so much for the quick response!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

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

Community Treasure Hunt

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

Start Hunting!

Translated by