function or code can detect the increment of force equations ?

1 回表示 (過去 30 日間)
Ahmed Nabil
Ahmed Nabil 2016 年 1 月 25 日
コメント済み: Chad Greene 2016 年 1 月 25 日
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 Center および File ExchangeMATLAB についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by