필터 지우기
필터 지우기

function or code can detect the increment of force equations ?

조회 수: 4 (최근 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 CenterFile Exchange에서 NaNs에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by