Fplot warnings, fails on array input.
8 次查看(过去 30 天)
显示 更早的评论
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 个评论
Rohit Reddy Madasani
2016-6-3
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
2016-6-3
The warning is saying that your code could be executed more quickly if you made the changes Rohit indicates.
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Surface and Mesh Plots 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!