Answer to Question #305528 in MatLAB for Mr Z

Question #305528

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]ย 

1
Expert's answer
2022-03-03T09:59:26-0500
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);





Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS