Fplot warnings, fails on array input.

8 visualizaciones (últimos 30 días)
Rasmus Svendsen
Rasmus Svendsen el 31 de Mayo de 2016
Comentada: Walter Roberson el 3 de Jun. de 2016
Hello. I'm new to Matlab. I just got a new PC, and now getting warnings using fplot. I cant find out whats wrong. The plot shows up, but i dont know how the warnings effects the plot.
Does anyone know what to do?
Thnaks
>> c = @(T) 0.0002374*T^3-0.05304*T^2+4.591*T+1450.59;
fplot(c,[2 30])
grid
title('Lydhastighed i havvand (dybde = 100 m, saltindhold = 3,5 pct)')
xlabel('Temperatur (grader C)')
ylabel('Lydhastighed (m/s)')
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)
  2 comentarios
Rohit Reddy Madasani
Rohit Reddy Madasani el 3 de Jun. de 2016
Hi Rasmus,
The warning clearly indicates that the operators involved in computing "c" are not element-wise operators. These warnings can be avoided by replacing the operators * and ^ with element-wise operators .* and .^ respectively.
c = @(T) 0.0002374.*T.^3-0.05304.*T.^2+4.591.*T+1450.59;
More information on array vs matrix operations can be found in the below link:
Walter Roberson
Walter Roberson el 3 de Jun. de 2016
The warning is saying that your code could be executed more quickly if you made the changes Rohit indicates.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

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

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by