Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
averaging

Subject: averaging

From: Micheal

Date: 8 Mar, 2013 10:36:08

Message: 1 of 5

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

Subject: averaging

From: anyone

Date: 8 Mar, 2013 14:23:36

Message: 2 of 5

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

Subject: averaging

From: Micheal

Date: 11 Mar, 2013 08:17:07

Message: 3 of 5

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

Subject: averaging

From: John D'Errico

Date: 11 Mar, 2013 14:36:07

Message: 4 of 5

"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

Subject: averaging

From: anyone

Date: 11 Mar, 2013 18:29:11

Message: 5 of 5

On Mon, 11 Mar 2013 08:17:07 +0000, Micheal wrote:

> 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

Knowledge and understanding are not automatic. Tools don't 'explain themselves'. If, as you wrote, you're unfamiliar
with tools and capability of Matlab, and you hope to (say) eventually execute non-trivial processing of arrays, you
should first spend some time in discovery of what Matlab can do and the different kinds of tools that are available.
Further, purchase of 'a Matlab license' does -not- grant the user access to all of the available toolsets. By now there
is a rather large number of other sub-licenses for tools and support that are also available for purchase, though you
probably don't need access to all of them. Were I you, I would follow the above with some kind of review TMW's
supporting products. (Google is your friend.)

Hence the the suggestion, "Help -> Getting Started." I believe it's fair to claim that nearly every other current user of
Matlab followed that approach at some point, the next question is, why not you too?

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us