# Function plot limits produces errors

2 visualizaciones (últimos 30 días)
Gavin Seddon el 21 de Jun. de 2016
Respondida: the cyclist el 21 de Jun. de 2016
fplot (@(x) was used to generate a figure the resulting curve shape is wrong and errors are produced. The correct X minimum and maximum values were not represented correctly. my command Used was taken from the 'help' menu. The errors were
>> fplot (@(x) (1211*x^6)/2500 + (9953*x^5)/10000 + (193*x^4)/125 - (681*x^3)/200 - (9549*x^2)/10000 + (3117*x)/1000 + 304/25, [0, 40000])
Warning: Function fails on array inputs. Use element-wise operators to increase speed.
> In matlab.graphics.function.FunctionLine>getFunction
In matlab.graphics.function.FunctionLine/set.Function_I
In matlab.graphics.function.FunctionLine/set.Function
In matlab.graphics.function.FunctionLine
In fplot>singleFplot (line 223)
In fplot>@(f)singleFplot(cax,{f},limits,extraOpts,args) (line 182)
In fplot>vectorizeFplot (line 182)
In fplot (line 153)
is the error with my limits? Can anyone help? G.
##### 1 comentarioMostrar -1 comentarios más antiguosOcultar -1 comentarios más antiguos
Karan Gill el 21 de Jun. de 2016
Your command works fine for me. Can you explain why the resulting curve is wrong? I don't see an error in your output -- only a warning.

Iniciar sesión para comentar.

the cyclist el 21 de Jun. de 2016
You are getting that warning because you are using array multiplication in your function. Try this instead:
fplot (@(x) (1211*x.^6)/2500 + (9953*x.^5)/10000 + (193*x.^4)/125 - (681*x.^3)/200 - (9549*x.^2)/10000 + (3117*x)/1000 + 304/25, [0, 40000])
Note that I used element-wise multiplication in the function.
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

### Categorías

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

### Community Treasure Hunt

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

Start Hunting!

Translated by