Table 1: Driving styles associated with acceleration values
Driving style Economic (1) Normal (2) Aggressive (3)
Acceleration magnitude [m/s2 ] 0.7-2.3 2.31-3.30 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.
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 ] 0.7-2.3 2.31-3.30 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
%}
A = [0.7, -2.3, 2.31, -3.30, 3.31, -8.5]
NORMAL = 2;
ECONOMIC = 5;
AGGRESSIVE=8;
for r=1:length(A)
if(abs(A(r))<=NORMAL),
fprintf('\n\nDriving Style: Normal, Acceleration = %.2f m/s2',A(r));
end
if(abs(A(r))>NORMAL && abs(A(r))<=ECONOMIC),
fprintf('\n\nDriving Style: Economic, Acceleration = %.2f m/s2',A(r));
end
if(abs(A(r))>ECONOMIC),
fprintf('\n\nDriving Style: Agressive, Acceleration = %.2f m/s2',A(r));
end
end
fprintf('\n\n');
Matlab utput:
A =
0.7000 -2.3000 2.3100 -3.3000 3.3100 -8.5000
Driving Style: Normal, Acceleration = 0.70 m/s2
Driving Style: Economic, Acceleration = -2.30 m/s2
Driving Style: Economic, Acceleration = 2.31 m/s2
Driving Style: Economic, Acceleration = -3.30 m/s2
Driving Style: Economic, Acceleration = 3.31 m/s2
Driving Style: Agressive, Acceleration = -8.50 m/s2
>>
Comments
Leave a comment