LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to mean 2D continuous data?

Solved!
Go to solution

Given that you have to produce all 6 elements of the array at once (since you need to "feed" them into six MeanPtByPt separate routines), I think the simple Array-to-Cluster followed by Unbundle Cluster is much simpler than six Index Arrays with constants 0, 1, 2, 3, 4, 5 wired into each one (less messy, as well).  Now, if you could do it in a loop ...   [Hmm -- of course, here's another way that doesn't even need Index Arrays ...]Multi-Channel Running Average 2

The outer loop isolates each sample point, giving you an array whose values represent the various channels.  The inner loop does the averaging for each channel.  If you want to average a particular channel, put a dedicated MeanPtByPt function inside its Case selector, else just wire straight through (you'll need a Default entry with a straight-through wire, so it can handle all the "Do Not Average" channels).  This is certainly simpler and more straight-forward than my earlier Array-to-Cluster + Unbundle, followed by Build Array.

Message 11 of 18
(2,753 Views)

Hi Bob,

 

"I think the simple Array-to-Cluster followed by Unbundle Cluster is much simpler than six Index Arrays with constants 0, 1, 2, 3, 4, 5 wired into each one"

Ever thought about resizing the IndexArray node? And (after reading the help) you could also omit the constants...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 12 of 18
(2,751 Views)

Citras,

     I don't understand the format of your data.  It does not seem to be a simple 2-D array of Dbls, but a more complex form.  If I knew the structure of the data array, I could tell you how to "tease it apart" to process it.  Take a look at my just-previous post, where I broke the 2-D array up into an array of "single-sample information", which (in the inner loop) I treated as though it, too, was a simple 1-D array of samples, one per channel.  However, in your case, I'm guessing that the "sample" is a slightly more complex structure, perhaps a multi-channel Waveform (as I see "time" in your output).  The trick is to simply break apart the inner "sample", feed each "channel" data into its own "averager", then reassemble it.

0 Kudos
Message 13 of 18
(2,748 Views)
Solution
Accepted by Citras

@BOB Schor wrote:

I think the simple Array-to-Cluster followed by Unbundle Cluster is much simpler than six Index Arrays with constants 0, 1, 2, 3, 4, 5 wired into each one (less messy, as well).


The array-to-cluster-unbundle-dance is actually much messier than you think.

(Your point was slightly more valid in ancient LabVIEW version (4?) where "index array" was not resizeable)

 

Here's equivalent code. As you can see, (A) has several problems over (B) as listed.

Message 14 of 18
(2,735 Views)

@GerdW wrote:

Hi Bob,

 

"I think the simple Array-to-Cluster followed by Unbundle Cluster is much simpler than six Index Arrays with constants 0, 1, 2, 3, 4, 5 wired into each one"

Ever thought about resizing the IndexArray node? And (after reading the help) you could also omit the constants...


Gerd,

     I don't understand your comment about resizing the Index Array node (I do know what this means), and, even after reading the help, I don't see how you can "omit the constants" if you want to present each array element to a separate "averaging" VI.  Maybe you are thinking about doing the averaging in some other way (which is fine), but if you want to do point-by-point averaging, you need to get the points one-at-a-time.

     Ah.  If I have an array of 1000 samples of 6 channels, I can, of course, extract multiple 100-sample sub-arrays from each channel and pass them to a single (!!) Mean VI, giving me a way of processing the first 900 samples (this could certainly be done with dual-indexing the 2D array), but (a) you wouldn't process the entire array this way, and (b) it doesn't lend itself to "on-the-fly" processing (e.g. smoothing the data as it's being collected for showing on a display).

     Now, I think I get it ...

0 Kudos
Message 15 of 18
(2,734 Views)

Thanks!  I didn't know this trick (this must be what Gerd was referring to -- I totally missed the point, nor was it obvious to me even after I read the Index Array Help message).  I totally agree that this is a better method of pulling out all the array elements than my Array-to-Cluster + Unbundle!

0 Kudos
Message 16 of 18
(2,728 Views)

Bob,  You've been on the forums a long time. I'm surprised you hadn't seen an expandable Index Array before.  Or the Array to Cluster in the Rube Goldberg thread.

0 Kudos
Message 17 of 18
(2,713 Views)

All of your comment are very helpful, it´s working now..

Thx for the help, here some kudos Smiley Happy

0 Kudos
Message 18 of 18
(2,692 Views)