LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Averaging values in 2-D Array in a circular area

Solved!
Go to solution
I'm trying to average temperature values in a 2-D array, rectangular coordinates, over a circular area.  Is there a sub-array function that works in polar coordinates, that I could utilize?  Any suggestions would be much appreciated.
0 Kudos
Message 1 of 38
(6,409 Views)

In the Mathematics >> Numeric >> Complex palette there are conversion functions to convert to any other complex type.  Then you can use other functions that work with complex data in those types.

 

0 Kudos
Message 2 of 38
(6,368 Views)
My professor found out a simple but crude solution,  by using a couple for loops to go through each point in the 2-d array and checking if the distance from the circle's center point is within a specified radius.
0 Kudos
Message 3 of 38
(6,341 Views)

Is the array always the same size?

 

Easiest would be to create a "mask' array that is "1" in inside the circular area, and "0" outside. Now just multiply the mask with your array and then use "add array elements" on this result and on the mask array. divide the two numbers to get the average. No loops needed.

 

can you attach a VI containing some typical data?

Message Edited by altenbach on 07-02-2009 10:33 AM
Message 4 of 38
(6,332 Views)

Perhaps you should first take a square subarray (with the size of your circular region of interest) from your 2-D Array and than proceed with your profs idea or with Altenbachs idea. This could save some computing time by avoiding unnecessary comparisons or multiplications.

 

Jörn 

0 Kudos
Message 5 of 38
(6,320 Views)

http://forums.ni.com/ni/board/message?board.id=170&message.id=384632&query.id=227790#M384632

 

The solution I came up with is discussed near the bottom of the page.

--
Tim Elsey
Certified LabVIEW Architect
0 Kudos
Message 6 of 38
(6,317 Views)

Here's a quick example of what I had in mind (LabVIEW 8.5).

 

You can move the circle with the cursor and change the radius. See if it makes sense. 😉

 

 

(It's pretty crude, but shows the main idea. Many improvements are possible)

 

 

 

 

Message Edited by altenbach on 07-02-2009 03:55 PM
Download All
Message 7 of 38
(6,304 Views)

this should do it

Pathogrean.PNG


"Should be" isn't "Is" -Jay
0 Kudos
Message 8 of 38
(6,293 Views)

Jeff, I think two loops are enough. 🙂

 

We also should accumulate the sum in a scalar, e.g. as follows, no need to built an array:

 

 

It's less pretty compared to my previous post, because we are flying blind, but operated pretty much "in place". This is good for a "code only" solution, where we don't need visual feedback.

 

Or we could only graph the "counted" points as follows:

 

 

 

 

 

Message Edited by altenbach on 07-02-2009 09:14 PM
Message 9 of 38
(6,279 Views)

altenbach wrote:

Or we could only graph the "counted" points as follows:


Seems we can only attach 3 items. Here's the code for the last option (LabVIEW 8.5.1).

 

 

0 Kudos
Message 10 of 38
(6,274 Views)