MATLAB Answers

how to calculate Minimunm, maximum and average values using the script

30 views (last 30 days)
write a script to:
Extract the following data from the ev data (attached).
Pack T1 C
Pack T2 C
Pack T3 C
Pack T4 C
2. The extracted data represent temperature measured from four sensors located around the battery pack. Calculate minimum, maximum and average temperature for each sensor.
3. Use bar command to plot at the same figure the calculated minimum, maximum and average values for each sensor. Add legend, grid and title to the figure. Add labels to all axes.

  0 Comments

Sign in to comment.

Accepted Answer

Pawel Jastrzebski
Pawel Jastrzebski on 8 Mar 2018
Edited: Pawel Jastrzebski on 8 Mar 2018
% Step 1: IMPORT DATA
fileName = 'Log_U0006387_160311_740d0.csv';
data = readtable(fileName)
% STEP 2: extract the data of interest to a new table
T_subData = data(:,{'PackT1C', 'PackT2C', 'PackT3C', 'PackT4C'})
% STEP 3: carry out required calculations
nomVal = mean(T_subData{:,:})
minVal = min(T_subData{:,:})
maxVal = max(T_subData{:,:})
% arrange data in respect the the TC
% preallocate
allDataRearraged = zeros(length(nomVal),3);
for i = 1:length(nomVal)
allDataRearraged(i,1) = minVal(i);
allDataRearraged(i,2) = nomVal(i);
allDataRearraged(i,3) = maxVal(i);
end
% STEP 4: plot the results
figure
bar(allDataRearraged)
title('Results')
xlabel('x values')
xticklabels(T_subData.Properties.VariableNames)
ylabel('Temperature')
legend({'min','nominal','max'},'Location','best')

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by