Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.



Re: averaging
Posted:
Mar 11, 2013 10:36 AM


"Micheal" wrote in message <khk3u3$l2v$1@newscl01ah.mathworks.com>... > anyone <jaup@h/WSWLG{nR1Â³qHe> wrote in message <5139f468$0$58835$c3e8da3$c8b7d2e6@news.astraweb.com>... > > On Fri, 08 Mar 2013 10:36:08 +0000, Micheal wrote: > > > > > Dear Matlab users, > > > > > > I am new to Matlab so please go easy on me. I am trying to figure out > > > how to do radial averaging on matlab. To make things a bit simple, lets > > > say that I have a 4x4 matrix A with random numbers. I define a center > > > and then calculate the distance of each Matrix element(pixel) from that > > > center (in a for loop). Now, the martix element A11 and A44 should have > > > same distances from the center. What I want to do is to collect the > > > values of all the elements that fall within the same distance from the > > > center and sum them together. I will also need to count the number of > > > pixels for averaging. I can do this by hand (for a small matrix anyway) > > > but for large matrix I will have a much difficult time. I dont know how > > > to do things in matlab too well (like asking for pixels that fall within > > > same distance to be summed etc )so I would appreciate if you seasoned > > > users can help me out. > > > > > > Much thanks in advance for your help. > > > > > > > Micheal > > > > Help > Getting Started > > > > Thanks, but I have already gone through the getting stated tutorial and can do basic stuff outlined in that tutorial. I think to collect values that fall within the same distance is a more tricky problem which my basic knowledge of matlab fails to solve. > > Micheal
First, you don't need a loop. If you are trying to learn MATLAB, why not learn how to use the full capabilities of the tool? Use it like it is designed to be used.
So learn how to use mesh grid. It will give you a set of element coordinates for all the elements of your array at once.
Next, learn how to compute ALL of the distances in one step.
Then there are tools that can help you to compute a statistic over all elements with the same distance. My consolidator (from the file exchange) is one.
John



