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 😊
Solved! Go to Solution.
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).
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
Thanks for the fast Reply.
But is there any shorter and easier Solution for this Problem without Programming?
Look again to my post: movavg is built in.
Success!
Luc
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).
Thanks, the first Example was the Perfect Solution 😎