Why is fsurf complaining when it plots -e^(-x^2)?
1 次查看(过去 30 天)
显示 更早的评论
I wanted to plot:
with fsurf however, when I tried it complained about errors, what I did was:
>> fsurf(@(x,y) -exp( -(x)^2), [-10 10 -10 10])
why does that give the following error:
Warning: Function behaves unexpectedly on array inputs. To
improve performance, properly vectorize your function to return
an output with the same size and shape as the input arguments.
> In matlab.graphics.function.FunctionSurface>getFunction
In matlab.graphics.function.FunctionSurface/updateFunction
In matlab.graphics.function.FunctionSurface/set.Function
In matlab.graphics.function.FunctionSurface
In fsurf>singleFsurf (line 261)
In fsurf>@(f)singleFsurf(cax,{f},extraOpts,args) (line 227)
In fsurf>vectorizeFsurf (line 227)
In fsurf (line 200)
>>
????
the plot it gives is ugly:
0 个评论
回答(1 个)
Star Strider
2018-1-13
The warnings disappear if you use element-wise operations (the ‘dot operator’ for the exponentiation), and the plot looks better if you reduce the x-range:
fsurf(@(x,y) -exp( -(x).^2), [-5 5 -10 10])
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Surface and Mesh Plots 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!