how to create an anonymous function?

1 次查看(过去 30 天)
Emil Goh
Emil Goh 2015-6-24
评论: Stephen23 2015-6-24
f(x,y)=x exp(-2y^2-x^2)
plot the surface of the function over R=[-2,2] x [-2,2]
  1 个评论
Stephen23
Stephen23 2015-6-24
Why do you need an anonymous function?
This is not required for plotting.

请先登录,再进行评论。

回答(2 个)

Guillaume
Guillaume 2015-6-24
编辑:Guillaume 2015-6-24
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 2015-6-24
x=[-2,2]
y=[-2,2]
[X,Y]=meshgrid(x,y)
Z=X.*exp(-2*Y.^2-X.^2)
surf(X,Y,Z)

类别

Help CenterFile Exchange 中查找有关 2-D and 3-D Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by