function or code can detect the increment of force equations ?

4 次查看(过去 30 天)
i have some equations like: 10*e^t or 20+sin(t), ...etc. it's force function of time. of course i can tell by looking to the plot that 'e^t for example' will keep increase as the the time increases, for sinusoidal shapes will be constant and so on..
my question is there any function or codes can do the same ? i just put the equation in matlab and he tells me in the result if force increased with time or not.
  2 个评论
jgg
jgg 2016-1-25
Why not just do this:
fun = @(t)(10*e^t);
increase = fun(0) > fun(1e10);
decrease = fun(0) < fun(1e10);
same = fun(0) == fun(1e10);
Or something like that?
Chad Greene
Chad Greene 2016-1-25
Picking two points arbitrarily is sensitive to high-frequencies, such as in the case of sin(t). The low-frequency trend of sin(t) is zero, but if you pick sin(0) and sin(1e10) it'll give a negative trend.

请先登录,再进行评论。

采纳的回答

Chad Greene
Chad Greene 2016-1-25
You could fit a least squares trend line over some predefined range to determine slope.
% define some array of times:
t = 1:500;
% define a function:
f = 10*sin(t);
% fit a straight line to the function:
P = polyfit(t,f,1);
% Get the slope of the trendline:
slope = P(1);
% Round the slope of the trendline to prevent a few eps from adjusting the sign:
slope = fix(slope*1000)/1000;
% Does the function increase (1), decrease (-1), or remain constant (0)?
sign(slope)
% plot:
plot(t,f,'b')
hold on
plot(t,slope*t+P(2),'k')

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 NaNs 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by