Why is fsurf complaining when it plots -e^(-x^2)?

1 visualización (últimos 30 días)
Brando Miranda
Brando Miranda el 13 de En. de 2018
Respondida: Star Strider el 13 de En. de 2018
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:

Respuestas (1)

Star Strider
Star Strider el 13 de En. de 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])

Categorías

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

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by