# Answer to Question #45299 in MatLAB | Mathematica | MathCAD | Maple for Rekha

Question #45299
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.
1
2014-09-02T01:47:41-0400
close all; clear all; clc;
N = 10000;
xlow = input('Enter Xlow: ');
xhigh = input('Enter Xhigh: ');
if xhigh < xlow
disp('Xhigh must be bigger then Xlow! Try again!')
else
X = xlow + (xhigh - xlow).*rand(1,N);
X_m = sum (X)/N;
X_rms = sqrt(sum (X.^2)/N);
X_gm = prod(X.^(1/N));
X_hm = N/sum(1./X);
disp(['Average of X = ', num2str(X_m)]);
disp(['Root mean square of X = ', num2str(X_rms)]);
disp(['Geometric mean of X = ', num2str(X_gm)]);
disp(['Harmonic mean of X = ', num2str(X_hm)]);
end

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!