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