how to create an anonymous function?

1 visualización (últimos 30 días)
Emil Goh
Emil Goh el 24 de Jun. de 2015
Comentada: Stephen23 el 24 de Jun. de 2015
f(x,y)=x exp(-2y^2-x^2)
plot the surface of the function over R=[-2,2] x [-2,2]
  1 comentario
Stephen23
Stephen23 el 24 de Jun. de 2015
Why do you need an anonymous function?
This is not required for plotting.

Iniciar sesión para comentar.

Respuestas (2)

Guillaume
Guillaume el 24 de Jun. de 2015
Editada: Guillaume el 24 de Jun. de 2015
Aren't the example in the documentation clear enough?
In this case (assuming the missing operator between x and exp is a multiplication):
f = @(x, y) x.*exp(-2*y.^2-x.^2);
Note: this is an answer to your question title: "How to create an anonymous function".

Azzi Abdelmalek
Azzi Abdelmalek el 24 de Jun. de 2015
x=[-2,2]
y=[-2,2]
[X,Y]=meshgrid(x,y)
Z=X.*exp(-2*Y.^2-X.^2)
surf(X,Y,Z)

Categorías

Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by