How do I indicate phase changes on my velocity versus time plot on MATLAB?
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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)
Can someone please help me?
0 commentaires
Réponses (1)
madhan ravi
le 10 Fév 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;
v = gradient(d) ./ gradient(t);
figure(1)
dvdt = gradient(v) ./ gradient(t);
%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)')
0 commentaires
Voir également
Catégories
En savoir plus sur Bar Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!