62 478
Assignments Done
98,8%
Successfully Done
In June 2018

Answer to Question #45547 in MatLAB | Mathematica | MathCAD | Maple for VISHNUJITH

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.
Expert's answer
% Input
xlow = input('xlow: ');
xhigh = input('xhigh: ');
 
% Random array
array = randi([xlow xhigh], 1, 10000);
 
% Arithmetic mean
AM = mean(array);
% Quadratic mean
QM = sqrt(mean(array.^2));
% Geometric mean
GM = geomean(array);
% Harmonic mean
HM = harmmean(array);
 
% Output
fprintf('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 first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions