From: jenya polyakova on
a matlab function? I have a vector of data DATA and also respective X and Y coordinate vectors of the same length as data. I need to divide my area into rectangular boxes and then calculate the mean (based on my DATA) for each of these box. Is there a function like that in Matlab? Thanks
From: ImageAnalyst on
On Feb 19, 12:27 pm, "jenya polyakova" <jeny...(a)yahoo.com> wrote:
> a matlab function? I have a vector of data DATA and also respective X and Y coordinate vectors of the same length as data. I need to divide my area into rectangular boxes and then calculate the mean (based on my DATA) for each of these box. Is there a function like that in Matlab? Thanks

------------------------------------------
Use blkproc() and mean()
It's been recently discussed:

http://www.mathworks.com/matlabcentral/newsreader/view_thread/272121#714461

From: jenya polyakova on
Thanks for reply. I was wondering if we run, for example,
T=rand(686,6);
P = blkproc(T,[10 1], @mean);
It returns P of size 69x6.
I would like it to return the same dimensions as T except that it would have appropriate block means (i.e. P) in each node.
Thanks.










ImageAnalyst <imageanalyst(a)mailinator.com> wrote in message <932a5ac8-bd72-48e8-93a9-ff301e1dd7fb(a)g28g2000yqh.googlegroups.com>...
> On Feb 19, 12:27 pm, "jenya polyakova" <jeny...(a)yahoo.com> wrote:
> > a matlab function? I have a vector of data DATA and also respective X and Y coordinate vectors of the same length as data. I need to divide my area into rectangular boxes and then calculate the mean (based on my DATA) for each of these box. Is there a function like that in Matlab? Thanks
>
> ------------------------------------------
> Use blkproc() and mean()
> It's been recently discussed:
>
> http://www.mathworks.com/matlabcentral/newsreader/view_thread/272121#714461
From: Ashish Uthama on
On Fri, 19 Feb 2010 12:53:04 -0500, jenya polyakova <jenya56(a)yahoo.com>
wrote:

> Thanks for reply. I was wondering if we run, for example, T=rand(686,6);
> P = blkproc(T,[10 1], @mean);
> It returns P of size 69x6.
> I would like it to return the same dimensions as T except that it would
> have appropriate block means (i.e. P) in each node. Thanks.
>


Look at the doc for IMFILTER, FSPECIAL :

>> a=magic(5)

a =

17 24 1 8 15
23 5 7 14 16
4 6 13 20 22
10 12 19 21 3
11 18 25 2 9

>> imfilter(a,fspecial('average',3))

ans =

7.6667 8.5556 6.5556 6.7778 5.8889
8.7778 11.111 10.889 12.889 10.556
6.6667 11 13 15 10.667
6.7778 13.111 15.111 14.889 8.5556
5.6667 10.556 10.778 8.7778 3.8889

>> mean([23 5 7 4 6 13 10 12 19]) %consider the (3,2) element (6) in 'a'.
>> The 3x3 average around it is:

ans =

11

>>
From: jenya polyakova on
I am not sure I understand. What if I want blocks of size 10x10.
I think mat2cell might work for me but I am yet to figure out how it works: where is there starting position if, say, I have 235x56 matrix and want to divide it into 2.5x2.5 blocks? Thanks


"Ashish Uthama" <first.last(a)mathworks.com> wrote in message <op.u8dy0q17a5ziv5(a)uthamaa.dhcp.mathworks.com>...
> On Fri, 19 Feb 2010 12:53:04 -0500, jenya polyakova <jenya56(a)yahoo.com>
> wrote:
>
> > Thanks for reply. I was wondering if we run, for example, T=rand(686,6);
> > P = blkproc(T,[10 1], @mean);
> > It returns P of size 69x6.
> > I would like it to return the same dimensions as T except that it would
> > have appropriate block means (i.e. P) in each node. Thanks.
> >
>
>
> Look at the doc for IMFILTER, FSPECIAL :
>
> >> a=magic(5)
>
> a =
>
> 17 24 1 8 15
> 23 5 7 14 16
> 4 6 13 20 22
> 10 12 19 21 3
> 11 18 25 2 9
>
> >> imfilter(a,fspecial('average',3))
>
> ans =
>
> 7.6667 8.5556 6.5556 6.7778 5.8889
> 8.7778 11.111 10.889 12.889 10.556
> 6.6667 11 13 15 10.667
> 6.7778 13.111 15.111 14.889 8.5556
> 5.6667 10.556 10.778 8.7778 3.8889
>
> >> mean([23 5 7 4 6 13 10 12 19]) %consider the (3,2) element (6) in 'a'.
> >> The 3x3 average around it is:
>
> ans =
>
> 11
>
> >>