How to identify negative slope from plot data?

8 ビュー (過去 30 日間)
Michael Tognotti
Michael Tognotti 2022 年 12 月 2 日
回答済み: Sam Chak 2022 年 12 月 2 日
So I'm trying to do some lap simulation work and I want to isolate the braking zones (negative slope) from a velocity vs. time data plot. I was thinking I could get it to identify mins/maxs but I would still need to identify if the region is sloped downward. How can I get the program to recognize that?

回答 (2 件)

KSSV
KSSV 2022 年 12 月 2 日
t = linspace(0,2*pi) ;
y = sin(t) ;
m = [0 diff(y)./diff(t)] ;
plot(t,y) ;
hold on
plot(t(m<0),y(m<0),'+r')
plot(t(m>=0),y(m>=0),'+g')
legend('sine','negative slope','positive slope')

Sam Chak
Sam Chak 2022 年 12 月 2 日
This is just a basic idea for identifying the region of negative slope. Generally, the numerical differentiation of the velocity data is obtained.
t = linspace(0, 180, 1801);
V = sin(2*pi/180*t); % velocity data
dV = gradient(V, t)/(2*pi/180); % numerical differentiation of V: cos(2*pi/180*t)
plot(t, [V' dV'], 'linewidth', 1.5), grid on,
ylim([-1.5 1.5]), yline(0, '--')
xlabel('t'), legend('V', 'dV', '')
xtval = 0:15:180; xticks(xtval)
idx = find(dV < 0);
slopeStart = t(idx(1))
slopeStart = 45.1000
slopeEnd = t(idx(end))
slopeEnd = 134.9000
The region of negative slope lies between and .

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by