Fplot warnings, fails on array input.
8 views (last 30 days)
Show older comments
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 Comments
Rohit Reddy Madasani
on 3 Jun 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
on 3 Jun 2016
The warning is saying that your code could be executed more quickly if you made the changes Rohit indicates.
Answers (0)
See Also
Categories
Find more on Surface and Mesh Plots in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!