Plot on the same figure the calculated acceleration and the classification variable ds mapping against time. Use left side y-axis and a line style to plot the acceleration. Use right side y-axis to illustrate the driving style classification. Hint: You may use plotyy to complete this task. Add labels to all axes. Add legend to the figure.
Table 1 below : Example of classification
acceleration value
-1.2 1
1.23 1
3.2 2
-4.3 3
9.5 0
ds mapping values
1
1
2
3
On the same figure plot all four obtained powers in kW against time. Use different line styles for each power, e.g. solid line, dashed line, dotted line or dash-dot line. Add labels to all axes. Add title, legend and grid to the figure.
t = 0:1:100; %Time Step
Load = 10; % Ohms
P=[ ]; %power
Vel = [ ]; %Speed
Gear= [ ]; %Gear
SOC = [ ]; %Soc
V = [ ]; %Voltage
A = [ ]; %Current
for r=1:length(t)
V(r)=100*rand;
A(r) = V(r)/Load;
P(r) = V(r) * A(r);
Vel(r) = V(r)*rand();
SOC(r) = Vel(r)*rand;
Gear(r) = SOC(r)*rand();
end
scrsz = get(0,'ScreenSize');
Dim=0;
figure('Position',[scrsz(1)+Dim, scrsz(2)+Dim,scrsz(3)-20,scrsz(4)-100]);
Use the battery voltage and current data imported to calculate the battery power P as follows
P = UI where P is the battery power [W], U is the battery voltage [V] and I is the battery current
[A] battery voltage in V [Pack Volts]
battery current in A [Pack Amps]
2. Plot each variable listed below against time in a form of subplot.
There should be 6 subplots in a single figure aligned in 2 columns and 3 rows.
Use different line colour for each data. Add labels to all axes.
• time in seconds [Time]
• speed in km/h [Speed]
• gear [Gear]
• elevation in meters [Elv]
• SOC (state-of-charge) in % [SOC]
• battery voltage in V [Pack Volts]
• battery current in A [Pack Amps]
%}
On the same figure plot all four obtained powers in kW against time. Use different line styles for each power, e.g. solid line, dashed line, dotted line or dash-dot line. Add labels to all axes. Add title, legend and grid to the figure.
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:
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.
Data extracted:
time in seconds [Time]
• speed in km/h [Speed]
• Motor Pwr (50w)
• Aux Pwr (50w)
• A/C Pwr (100w)
Assign the extracted data to variables. Note that appropriate conversion must be done to obtain power in kW for all variables. Use description in the “Log File Format.docx” to get more details about conversion rates
Plot on the same figure the calculated acceleration and the classification variable ds mapping
against time. Use left side y-axis and a line style to plot the acceleration. Use right side
y-axis to illustrate the driving style classification. Hint: You may use plotyy to complete this
task. Add labels to all axes. Add legend to the figure.
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
Ds mapping
NORMAL = 2;
ECONOMIC = 5;
AGGRESSIVE=8;
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
Use the battery voltage and current data imported to calculate the battery power P as follows P = UI where P is the battery power [W], U is the battery voltage [V] and I is the battery current [A]
battery voltage in V [Pack Volts]
battery current in A [Pack Amps]
2. Plot each variable listed below against time in a form of subplot. There should be 6 subplots in a single figure aligned in 2 columns and 3 rows. Use different line colour for each data. Add labels to all axes.
• time in seconds [Time]
• speed in km/h [Speed]
• gear [Gear]
• elevation in meters [Elv]
• SOC (state-of-charge) in % [SOC]
• battery voltage in V [Pack Volts]
• battery current in A [Pack Amps]
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