Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Average every three points
Replies: 1   Last Post: Nov 15, 2012 11:09 AM

 Messages: [ Previous | Next ]
 Loren Shure Posts: 1,067 Registered: 12/7/04
Re: Average every three points
Posted: Nov 15, 2012 11:09 AM

"Akram Nour" <akramonour@hotmail.com> wrote in message
news:k82v0a\$c7c\$1@newscl01ah.mathworks.com...
> I would like a sufficient way rather than using loop to average between
> every element with the previous and the following elements (neglecting the
> first and last elements); for instance:
> If I have as an input (a) with a size of (12x1)
> a= [ 3; 6; 4; 1; 3; 6; 7; 8; 5; 3; 2; 1];
>
> the output should be (b) with a size of (10x1) as follows b=[ 4.33; 3.66;
> 2.66; 3.33; 5.33; 7.00; 6.66; 5.33; 3.33; 2.00]
>

Look into the function filter. Your filter would be b = [1 1 1]/3, a = 1

--
Loren
http://blogs.mathworks.com/loren/
http://www.mathworks.com/matlabcentral/

Date Subject Author
11/15/12 Akram Nour
11/15/12 Loren Shure