Fplot warnings, fails on array input.
8 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Rohit Reddy Madasani
le 3 Juin 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
le 3 Juin 2016
The warning is saying that your code could be executed more quickly if you made the changes Rohit indicates.
Réponses (0)
Voir également
Catégories
En savoir plus sur Surface and Mesh Plots dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!