LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How I average data with 78,74,73 and 55 points respectively and end up with an array of 78 points for the average?

Hi
 
As the questions states, how do I average data with 78,74,73 and 55 points respectively and obtain an array of 78 points? 
 
When I use the plus vi, Labview somehow produces an array of 55 points when I do the average (see attached vi).
 
I have been unlucky in trying to get good results.
 
Can anyone help?
 
Thank you.
 
 
 
0 Kudos
Message 1 of 3
(2,762 Views)
The issue here is how you are holding your data prior to performing the average. LV 2D arrays are always rectangular, which is to say every row has the came number of columns (and vice versa). For example, if you combine two arrays with an unequal number of element to produce a 2D array, LV will pad the smaller of the two arrays with zeros to make it the same size as the larger one.
 
Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 2 of 3
(2,756 Views)
The add function is polymorphic. It accepts arrays as well as numerics, but you need to understand one thing about array operations in LV. Operations performed on arrays of different sizes will always (I think) work based on the smallest array. For example, if you auto index 2 arrays of different sizes into a for loop, the number of times the loop will run will be the size of the small array. The same is true here - when you wire 2 arrays of different sizes to the add function, only the first N elements of the larger array get processed. The rest are dumped. That's why you get 55 elements.
 
Attached is a modification of your VI which shows 2 things:
  • The bottom part is your algorithm, only cleaned up. Note how much easier it would be to read now. You should always write clean code. Also, note that I have changed the representation on some of the data from DBL to I32. This is because this is the representation the array function work with and your code had the DBLs coerced for no reason.
  • The top part is a different algorithm which should do what you want. Note that like Mike said, the arrays with smaller sizes will have 0s appended at the end, so if you want to avoid that, you will have to modify the last part, where the averaging is done and only divide those columns which are long enough.

To learn more about LabVIEW, I suggest you try searching this site and google for LabVIEW tutorials. Here and here are a couple you can start with. You can also contact your local NI office and join one of their courses.
In addition, I suggest you read the LabVIEW style guide and the LabVIEW user manual (Help>>Search the LabVIEW Bookshelf).


___________________
Try to take over the world!
0 Kudos
Message 3 of 3
(2,743 Views)