76 285
Assignments Done
Successfully Done
In May 2019

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.
Expert's answer
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!')
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)]);

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!


No comments. Be first!

Leave a comment

Ask Your question

Privacy policy Terms and Conditions