Question #45547
Write a single program that calculates the arithmetic mean (average), rms average, geometric mean and harmonic mean for a set of n positive numbers. Your program should take two values xlow and xhigh and generate 10000 random numbers in the range [xlow…xhigh], and should print out arithmetic mean (average), rms average, geometric mean and harmonic mean.
The definitions of means are given as follows.
1
Expert's answer
2014-09-03T04:21:34-0400
% Inputxlow = input('xlow: ');xhigh = input('xhigh: '); % Random arrayarray = randi([xlow xhigh], 1, 10000); % Arithmetic meanAM = mean(array); % Quadratic meanQM = sqrt(mean(array.^2));% Geometric meanGM = geomean(array);% Harmonic meanHM = harmmean(array); % Outputfprintf('Arithmetic mean: %.3f\n', AM);fprintf('Quadratic mean: %.3f\n', QM);fprintf('Geometric mean: %.3f\n', GM);fprintf('Harmonic mean: %.3f\n', HM);

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!
LATEST TUTORIALS
APPROVED BY CLIENTS