On Thu, Apr 2, 2020 at 1:04 PM Jim Donoghue <

[hidden email]> wrote:

>

> Hi Kwan.

>

> Thanks for your email. I’m using octave on MacBook and tried installing the signal package using the way you showed me. I got errors. I’ll try it again without using sum too.

Here's the script that works for me:

pkg load signal

pkg load statistics

N=5 %setting a value for N for 5 numbers

Sum=0 %initilalsing the sum to @ to be used to calculate sum

for i = 1:N %for Loop starting from 1 and ending at 5

In(i) = input('Please enter numbers: '); %asks user to input a number

and will loop 5 times

Sum = Sum + In(i); %used to calculate the sum

endfor

Am = 1/(N) * Sum; %Formula to find Aritmetric mean

Qm = sqrt((In(1)^2 + In(2)^2 + In(3)^2 + In(4)^2 + In(5)^2) / N);

%Formula to find Quadradic mear

Hm = N/ (1/In(1) + 1/In(2) + 1/In(3) + 1/In(4) + 1/In(5));%Formula to

find Harmonic mean

fprintf('\n The Arithmetic mean is %2.2f',Am); %Prints answer to screen

fprintf('\n The Quadratic mean is %2.2f',Qm);

fprintf('\n The Harmonic mean is %2.2f\n' ,Hm);

arithmetic = mean(In) %Finding the same answers using the build in functions

quadratic = rms(In)

harmonic = harmmean(In)

> --

> "Don't be lazy. Do the thing. Do it properly." - Simone Giertz

--

"Don't be lazy. Do the thing. Do it properly." - Simone Giertz