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. If the acceleration value is outside the defined ranges assign 0 as its classification.
Table 1 (4 by 2)
Driving style Economic (1) Normal (2) Aggressive (3)
Acceleration magnitude [m/s2 ] 0.7-2.3 2.31-3.30 3.31-8.5
Economic (1)
0.7-2.3
Normal (2)
2.31-3.30
Aggressive (3)
3.31-8.5
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');
Comments
Leave a comment