Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

NOTE: Do not write any fprintf statements. NOTE: Do not write the function defin

ID: 3698964 • Letter: N

Question

NOTE: Do not write any fprintf statements. NOTE: Do not write the function definition of stats4 (just write the function calls). 2) Write the function definition of a function named stats5 that calculates and returns the total, average, highest, lowest, standard deviation (sd), root mean square (RMS), and harmonic mean (H) of the elements of the array a. Use the variables tot_a, avg a, max a, min a, sd a, RMS_a, and H_a for the total, average, highest value, lowest value, standard deviation, root mean square and harmonic mean. The standard deviation, root mean square, and harmonic mean are given by: n(n-) hps://www.courscher e file/23647993/CSC1240-exam-2

Explanation / Answer

function [tot_a,avg_a,max_a,min_a,sd_a,RMS_a,H_a]=stats5(a)
n=numel(a);
tot_a=sum(a);
avg_a=tot_a/length(a);
max_a=max(a);
min_a=min(a);
sd_a=sqrt((n*sum(a.*a)-(sum(a))^2)/(n*(n-1)));
RMS_a=sqrt(sum(a.*a)/n);
H_a=n./(sum(1./a));