Why is fsurf complaining when it plots -e^(-x^2)?
1 view (last 30 days)
Show older comments
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 Comments
Answers (1)
Star Strider
on 13 Jan 2018
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 Comments
See Also
Categories
Find more on Surface and Mesh Plots in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!