help-octave
[Top][All Lists]

## Average contents of a matrix

 From: babelproofreader Subject: Average contents of a matrix Date: Mon, 2 Mar 2009 17:28:07 -0800 (PST)

```I want to average the contents of a matrix so that each value is the average
of all immediately adjacent values and itself: for example if I have a
simple 4 by 4 matrix e.g. a[ 1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16]

I would like to create a 4 by 4 matrix av[] so that av[1,1] is the average
of a[1,1], a[1,2], a[2,1] and a[2,2];
av[3,2] is the average of a[2,1], a[2,2], a[2,3], a[3,1], a[3,2], a[3,3],
a[4,1], a[4,2] and a[4,3]  etc...
giving a value for av[1,1] of 3.5 and av[3,2] a value of 10

Is there a function that can do this or will I have to loop through doing
the calculations or otherwise code it?

The purpose of this is to smooth a surface plot of a[] or create a surface
plot of the smoothed version of a[], i.e. av[].
--
View this message in context:
http://www.nabble.com/Average-contents-of-a-matrix-tp22300781p22300781.html
Sent from the Octave - General mailing list archive at Nabble.com.

```