Monthly power consumption in Megawatts (MW) for a manufacturing plant for a year
ID: 1926759 • Letter: M
Question
Monthly power consumption in Megawatts (MW) for a manufacturing plant for a year is given by the following data: The average yearly power consumption. Print your result to 2 decimal places and compare your result to the MA TLAB mean function.Explanation / Answer
P = [ 352.7, 279.3, 250.9, 186.1, 135.5, 159.9, 233.1, 297.7, 218.5, 216.4, 290.3, 370.0 ]; n = 12; P_max = 0; P_sum = 0; P_avg = 0; P_std = 0; max_month = 0; fprintf(' '); for i = 1:n if (P(i) > P_max) P_max = P(i); max_month = i; end P_sum = P_sum + P(i); end; P_avg = P_sum / n; fprintf('Calculated Averge: %6.2f ', P_avg); fprintf('MATLAB mean(): %6.2f ', mean(P)); fprintf(' '); for i = 1:n P_std = P_std + (P(i) - P_avg)^2; end; P_std = sqrt(P_std / (n-1)); fprintf('Calculated Standard Deviation: %6.3f ', P_std); fprintf('MATLAB std(): %6.3f ', std(P)); fprintf(' '); fprintf('MONTHLY POWER USE ABOVE THE YEARLY AVERAGE '); fprintf(' MONTH POWER USE (MW) '); for i = 1:n if (P(i) > P_avg) fprintf(' %3d %9.1f ',i,P(i)); end; end; fprintf(' '); fprintf('MAXIMUM MONTHLY POWER USE '); fprintf(' MONTH POWER USE (MW) '); fprintf(' %3d %9.1f ',max_month,P_max);
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.