From: Ashish Uthama on 19 Feb 2010 14:10 On Fri, 19 Feb 2010 13:29:05 -0500, jenya polyakova <jenya56(a)yahoo.com> wrote: > 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 Please have a look at the doc for FSPECIAL. You can provide a second argument to specify the neighbourhood size. imfilter(a,fspecial('average',10)) I am not sure mat2cell is a fit here. I do not understand the concept of a fractional block. It might help others answer your questions if you could clarify. This might help get an idea of using IMFILTER for mean: http://homepages.inf.ed.ac.uk/rbf/HIPR2/mean.htm The starting point is element (1,1) (is that what you are asking?). Since this point does not have a full neighborhood, the function needs to make some assumptions. By default, it assume non-existent neighbours are 0 valued. Look at the Boundary Options section of the IMFILTER doc, speciall the Boundary Options section for more info.
From: Ashish Uthama on 19 Feb 2010 14:21 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.
From: jenya polyakova on 19 Feb 2010 14:56 "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
From: Ashish Uthama on 19 Feb 2010 15:08 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.
From: jenya polyakova on 19 Feb 2010 15:13 "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).
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 Prev: Controlling different movements in simmechanics Next: nr load flow |