% 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);
Comments
Leave a comment