From: Ashish Uthama on 19 Feb 2010 15:23 n Fri, 19 Feb 2010 15:13:04 -0500, jenya polyakova <jenya56(a)yahoo.com> wrote: > "Ashish Uthama" <first.last(a)mathworks.com> wrote in message > <op.u8d4wawsa5ziv5(a)uthamaa.dhcp.mathworks.com>... >> On Fri, 19 Feb 2010 14:56:04 -0500, jenya polyakova >> <jenya56(a)yahoo.com> wrote: >> > "Ashish Uthama" <first.last(a)mathworks.com> wrote in message > >> <op.u8d2p0yda5ziv5(a)uthamaa.dhcp.mathworks.com>... >> >> On Fri, 19 Feb 2010 12:27:04 -0500, jenya polyakova >> >> <jenya56(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 >> >> Ok, I missed the part about having x/y coordinates. >> >> I guess you meant fractional blocks defined on the coordinate system. >> >> I would interpolate the data to convert fractional coordinates >> into >> full size blocks. >> >> %Sample existing data >> >> [x y]=meshgrid(5:8,3:6) >> >> d=rand(4,4) >> >> %Interpolate on a finer grid >> >> [xi yi]=meshgrid(5:.5:8,3:.5:6) >> >> di=interp2(x,y,d,xi,yi) >> >> follow with the filtering steps on di to get the mean. >> >> >> > I am not sure...here by interp you essentially create more data. I >> do > not want to do it. What I want to do it to place a box of certain >> size > (say 2.5x2.5) in the, say, lower, left corner. Then I would >> look how > many data points fall within that block. Let's say four >> point were > there. I would then assign the weight of (1/4) to each of >> the data. Then > I will move block to next position (non-overlapping). >> Perform the same > thing of assigning weights. Thing I worry about is >> boarder effect and > also point falling into the side of the box. It >> is easy code. But I was > wondering if it could be done by matlab >> stand alone functions. Thanks >> If its non-overlapping, why do you expect the output to be the same >> size as the input data? >> Anyway, I dont think there is a MATLAB function to do this. >> Hand coding is probably the best approach. > because we are not adding more data, nor do we delete data. We just > multiply our data by weights that are defined by the "size" (size in > this case is number of data points falling into the box). I guess I now understand what you are trying to do, I cant think of leveraging any MATLAB function to do this. If you have trouble hand coding, post back with sample data and the code you have created. |