Knowing that average acceleration in a time interval ∆t = ti+1 − ti can be expressed as 𝑎𝑖 = 𝑣𝑖+1 − 𝑣𝑖 / ∆𝑡
where vi+1 − vi is the change in velocity between successive measurements,
write a code to:
Calculate acceleration in m/s2 using speed and time data extracted from the dataset. Hint: You may use for ... end loop to complete this task.
Data extracted:
time in seconds [Time]
• speed in km/h [Speed]
close all,
clear all,
clc,
%{
Knowing that average acceleration in a time interval ?t = ti+1 ? ti can be expressed as ?? = ??+1 ? ?? / ??
where vi+1 ? vi is the change in velocity between successive measurements,
write a code to:
3) Calculate acceleration in m/s2 using speed and time data extracted from the dataset. Hint: You may use for ... end loop to complete this task.
Driving style Economic (1) Normal (2) Aggressive (3)
Acceleration magnitude [m/s2] 0.7-2.3 2.31-3.30 3.31-8.5
%}
%{
delta_t = 1; %seconds
t = 0:delta_t:20; %Time Stamp
v=[];
Acc=[];
for r=1:length(t)
v(r)=10+rand;
if(r==1) Acc(r)=0;
else
Acc(r) = (v(r)-v(r-1))/(t(r)-t(r-1));
end
end
scrsz = get(0,'ScreenSize');
Dim=0;
figure('Position',[scrsz(1)+Dim, scrsz(2)+Dim,scrsz(3)-20,scrsz(4)-100]);
plot(t,Acc,'r');
grid on,
xlabel('--- Time(t) --->');
ylabel('Acceleration');
title('Plot: Acceleration','FontSize',20);
Comments
Leave a comment