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
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 2016-6-3
The warning is saying that your code could be executed more quickly if you made the changes Rohit indicates.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Surface and Mesh Plots 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by