Answer to Question #303079 in MatLAB for MR Z

Question #303079

Table 1: Driving styles associated with acceleration values


Driving style Economic (1) Normal(2) Aggressive(3)

Acceleration magnitude [m/s2 ]


Economic (1)

0.7-2.3


Normal(2)

2.31-3.30


Aggressive(3)

3.31-8.5 


Create variable ds mapping to store corresponding classification values of 1,2 or 3, which represent different driving style as shown in Table 1. You need to evaluate only the magnitude the of the acceleration/deceleration


1
Expert's answer
2022-02-28T01:08:42-0500


close all,
clear all,
clc,


%{
    Table 1: Driving styles associated with acceleration values
    Driving style Economic (1) Normal(2) Aggressive(3)
    Acceleration magnitude [m/s2 ]


    Economic (1)    0.7-2.3
    Normal(2)       2.31-3.30
    Aggressive(3)   3.31-8.5 
    Create variable ds mapping to store corresponding classification values of 1,2 or 3, 
    which represent different driving style as shown in Table 1. 
    You need to evaluate only the magnitude the of the acceleration/deceleration
%}


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');



Matlab Output:



Acceleration = 0.70 m/sec^2: Driving Style: ECONOMIC CLASS: 1

Acceleration = -2.30 m/sec^2: Driving Style: ECONOMIC CLASS: 1

Acceleration = 2.31 m/sec^2: Driving Style: NORMAL: CLASS: 2

Acceleration = -3.30 m/sec^2: Driving Style: NORMAL: CLASS: 2

Acceleration = 3.31 m/sec^2: Driving Style: AGGRESSIVE: CLASS: 3

Acceleration = -8.50 m/sec^2: Driving Style: NORMAL: CLASS: 2

Acceleration = -8.50 m/sec^2: Driving Style: AGGRESSIVE: CLASS: 3


>> 


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