Question #45474

Write a single program in Matlab 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

Answer on Question #45474, Programming, Mat LAB | Mathematica | MathCAD | Maple

Question:

Write a single program in Matlab 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.

Answer:


function [arithmetic_mean, rms_average, geometric_mean, harmonic_mean] = program(xlow, xhigh)
    random_array = random('unif', xlow, xhigh, 10000, 1);
    arithmetic_mean = mean(random_array);
    rms_average = rms(random_array);
    geometric_mean = geomean(random_array);
    harmonic_mean = harmmean(random_array);
end


http://www.AssignmentExpert.com/

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!

LATEST TUTORIALS
APPROVED BY CLIENTS