cancel
Showing results for
Did you mean:
cancel
Showing results for
Did you mean:

## Calculation of the mean in an Array

SOLVED  4-Participant

## Calculation of the mean in an Array

Hi,

I have a simple Problem however I'm searching since nearly one hour for the solution.

I'm looking to calculate the mean in an Array. I Have R=(x1, x2, ....) and i want to calculate the mean of every value in the Array like Rm1=(x1+x2)/2 Rm2=(x2+x3)/2 ... and so on.
How does it work im Mathcad? The normal Matrix Indicies with i and i+1 doesn't work.

I also attached a short Version of the Mathcad file, especially to focus on this Problem. Thanks for helping 😊

1 ACCEPTED SOLUTION

Accepted Solutions  24-Ruby IV
(To:DG_8871348)

Here is your own approach using a range variable, but as the last element of the vector has no successor, the range to use must run only up to Anz.i-1 and so you can't use i, you need a new range variable - k in my example (but of course you also could redefine i for that purpose). Nonetheless I would prefer defining a small utility function But is there any shorter and easier Solution for this Problem without Programming?

Luc's "Mean2" function IS quite short (and can be written even a little bit shorter if you assume ORIGIN=0) does NOT use programming (so it could be used in the free Express version of Prime, too).

The built-in function "movavg" suggested by Luc makes the same calculations but always returns a vector of the same length by prepending first vector element. To get rid of it you may use the "submatrix" command (assuming ORIGIN=0 as is the case in your sheet).

5 REPLIES 5  23-Emerald I
(To:DG_8871348)

You do realise that the result of this operation produces an array that has one less elements...?

This is one way to do it: The result for your array is: There's also a built-in function for it: Moving average. Try:

movavg(Ri,2)

Success!
Luc  4-Participant
(To:LucMeekes)

But is there any shorter and easier Solution for this Problem without Programming?  23-Emerald I
(To:DG_8871348)

Look again to my post: movavg is built in.

Success!

Luc  24-Ruby IV
(To:DG_8871348)

Here is your own approach using a range variable, but as the last element of the vector has no successor, the range to use must run only up to Anz.i-1 and so you can't use i, you need a new range variable - k in my example (but of course you also could redefine i for that purpose). Nonetheless I would prefer defining a small utility function But is there any shorter and easier Solution for this Problem without Programming?

Luc's "Mean2" function IS quite short (and can be written even a little bit shorter if you assume ORIGIN=0) does NOT use programming (so it could be used in the free Express version of Prime, too).

The built-in function "movavg" suggested by Luc makes the same calculations but always returns a vector of the same length by prepending first vector element. To get rid of it you may use the "submatrix" command (assuming ORIGIN=0 as is the case in your sheet).  4-Participant
(To:Werner_E)

Thanks, the first Example was the Perfect Solution 😎 Announcements
Check out the latest