0
$\begingroup$

If I have a $500 \times 500$ matrix and I would like to replace every ($5n-1$) row with the average of $(5n-1)$ and $(5n)$. How would I be able to do this with Mathematica?

$\endgroup$
1
  • 1
    $\begingroup$ You might have better luck asking this on Mathematica SE $\endgroup$
    – Winther
    Commented Oct 5, 2017 at 21:21

1 Answer 1

0
$\begingroup$

Suppose $A$ is the matrix. Then this should work:

ReplacePart[A, Map[(# -> (A[[#]] + A[[# + 1]])/2) &, Table[5 k-1, {k, 1, 100}]]]
$\endgroup$
1
  • $\begingroup$ Perfect. Thank you so much. $\endgroup$
    – user372021
    Commented Oct 5, 2017 at 21:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .