function or code can detect the increment of force equations ?
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Ahmed Nabil
am 25 Jan. 2016
Kommentiert: Chad Greene
am 25 Jan. 2016
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 Kommentare
jgg
am 25 Jan. 2016
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
am 25 Jan. 2016
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.
Akzeptierte Antwort
Chad Greene
am 25 Jan. 2016
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')
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu NaNs finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!