# How do I indicate phase changes on my velocity versus time plot on MATLAB?

6 views (last 30 days)
Matthew Worker on 10 Feb 2021
Answered: madhan ravi on 10 Feb 2021
I have a graph that plots velocity versus time and I have to indicate where/which data point on the plot accelerates, stays constant, and decelerates. This is what I have for graphing my plot:
>> t = [1.85 2.87 3.78 4.65 5.5 6.32 7.14 7.96 8.79 9.69]
>> d = [10 20 30 40 50 60 70 80 90 100]
>> v = diff(d)./diff(t)
>> plot(v)
>> title('Time versus Velocity for Usain Bolt')
>> xlabel('Time(s)')
>> ylabel('Velocity(m/s)')
>> figure(1)

madhan ravi on 10 Feb 2021
t = [1.85 2.87 3.78 4.65 5.5 6.32 7.14 7.96 8.79 9.69];
d = 10: 10 : 100;
figure(1)
%deceleration:
t1 = t(dvdt < 0);
v1 = v(dvdt < 0);
%acceleration:
t2 = t(dvdt > 0);
v2 = v(dvdt > 0);
% P.S :constant part is quite tricky ;)
plot(t, v, '-*k', t1, v1, '-r*', t2, v2, '-g*')
legend({'Constant acceleration', 'Deceleration', 'Acceleration'}, 'location', 'best')
title('Time versus Velocity for Usain Bolt')
xlabel('Time(s)')
ylabel('Velocity(m/s)') 