- Community Home
- :
- Discussion Forums
- :
- Most Active Software Boards
- :
- LabVIEW
- :
- Array averaging issues

Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

06-17-2008 02:56 PM

Options

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

x y

0 .2

1 .3

2 .4

3 .5

0 .21

1 .32

2 .4

...

etc.

What would be the best method of averaging the repeated scans? Eventually, I will have to differentiate points using a third coordinate (-1, 0, and 1), and I will have to set up this program to be able to handle that, which is a further complication.

I apologize since this seems like it ought to be routine, but I have always had extreme trouble in dealing with arrays in LabView, especially with establishing indices in multidimensional arrays.

Thank you for whatever advice you can provide.

Please find attached my current VI so perhaps you can see better what I mean.

06-17-2008 03:06 PM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

Hi Matt G,

see the attached example picture.

Hope it helps.

Mike

see the attached example picture.

Hope it helps.

Mike

06-17-2008 03:55 PM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

So far this looks like exactly what I need, but I have been unable to identify one of the functions you used. What is the array function in the nested for loops?

I am grateful for your help. This has been waylaying me for a while.

06-17-2008 04:12 PM - edited 06-17-2008 04:13 PM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

it´s index array, followed by "Multiply Array Elements" and the "Divide" function.

Mike

Message Edited by MikeS81 on 06-17-2008 11:13 PM

06-17-2008 04:56 PM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

Since the x values are four integers starting with zero, you can output a 1D array of averages and use the array index for x.

What I would do:

Keep a 2D array and for each input pair increment element (x,0) by one and increment element (x,1) by y.

For each x (row), column 0 will contain the number of added elements, while column 1 will have the sum of all elements.

At the end, just divide column 1 by column 2 and you get a 1D array where x is the array index and each element is the average for that x.

Here's a quick example. There are many ways to do this, some are probably even simpler.

(btw: do you have any explanation why you use complex extended precision for some of the data in your VI????)

06-18-2008 01:59 PM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

About the complex extended precision, prior to that, data was being truncated, so I switched over to that format. I imagine that's a bit of overkill, eh?

Thanks to everyone here for help with this.

I need to modify this code sometime soon to deal with the third dimension I mentioned (-1, 0, and 1), I'm thinking of (somewhat wastefully) creating a 1D array that stores all those values, then somehow sort which data pairs belong in which of the three pairs of x and y axes and to average and take into account the fact that each pair of axes will not have equal numbers of data points (an x axis might read 0, 0.1, 0, 0.3, 0.4, where the third value was not entered).

Would you have any recommendations on how to implement that?

I may have to overhaul the program completely as it is since after approx. 24,000 measurements, it slows down significantly.

06-18-2008 02:40 PM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

First of all, correct code should not slow down significantly, so something else is wrong. You are growing arrays in shift registers without bounds, so this will tax the system after a while. You shoud stram the data ti disk and only accumulate the two fixed size 2D arrays as described below. Atleast you could clear the feedback nodes after each file write in your current implementation. There is also no reason in the world to do EXT and CXT datatypes. Way too much baggage for this application.

Here's a quick draft how you could do the 2D thingy. Just keep two 2D arrays in shift registers and for each data point, increment the element at x,z indices. One array keeps the sum of all elements and the other the count. At the end, just divide the two 2D arrays. Of course you would need to adjust the size of each dimension according to the desired granularity.

Well, a value of zero is not the same as a missing value. How can you tell the difference?

Matt G wrote:

(an x axis might read 0, 0.1, 0, 0.3, 0.4, where the third value was not entered).

06-26-2008 03:56 PM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

Now to get the instrument working properly .