How to identify negative slope from plot data?
조회 수: 4 (최근 30일)
이전 댓글 표시
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?
댓글 수: 0
답변 (2개)
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')
댓글 수: 0
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))
slopeEnd = t(idx(end))
The region of negative slope lies between
and
.
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
