How to identify negative slope from plot data?

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

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by