Answer to Question #303067 in MatLAB for MR Z

Question #303067

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


1
Expert's answer
2022-02-27T04:11:56-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