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

조회 수: 1 (최근 30일)
Brando Miranda
Brando Miranda 2018년 1월 13일
답변: Star Strider 2018년 1월 13일
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:

답변 (1개)

Star Strider
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])

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by