Answer to Question #303942 in MatLAB for MR Z

Question #303942

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


Table format: as seen above

Economic (1)

0.7-2.3

Normal (2)

2.31-3.30

Aggressive (3)

3.31-8.5


1
Expert's answer
2022-02-28T08:30:01-0500
close all,
clear all,
clc,

ECONOMIC    = 1;
NORMAL      = 2;
AGGRESSIVE  = 3;


% Acceleration magnitude [m/s2] 0.7-2.3 2.31-3.30 3.31-8.5
Acc = [0.7, -2.3, 2.31, -3.30, 3.31, -8.5];
ds_mapping = [ECONOMIC,NORMAL,AGGRESSIVE];
for r=1:length(Acc)
    if(abs(Acc(r))<=2.3), 
        fprintf('\n\tAcceleration = %5.2f m/sec^2:\t Driving Style: ECONOMIC\tCLASS: %d',Acc(r),ds_mapping(1));
    end
    if(abs(Acc(r))>2.3 && Acc(r) <= 3.30), 
        fprintf('\n\tAcceleration = %5.2f m/sec^2:\t Driving Style: NORMAL:\t\tCLASS: %d',Acc(r),ds_mapping(2));
    end
    if(abs(Acc(r))>3.3), 
        fprintf('\n\tAcceleration = %5.2f m/sec^2:\t Driving Style: AGGRESSIVE:\tCLASS: %d',Acc(r),ds_mapping(3));
    end
        
end
fprintf('\n\n');




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