How to identify negative slope from plot data?

9 次查看(过去 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?

回答(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