LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Averaging array contents

HI Keshav,

I thinkI ve answered your query already. Smiley Wink

Anyway, after getting your 1000 waveforms from your measuring device, bind them into an array, not 2D, just a 1D by using the Concatenate Inputs option of the Build Array function.

Then pass this array to the Mean VI or using Add Array Elements --> Divide by Array Size, you ll get the average of all those waveforms. Smiley Happy

- Partha ( CLD until Oct 2027 🙂 )
0 Kudos
Message 11 of 26
(1,644 Views)
Hi Keshav & Partha,

I think keshav wants to average 1000 waveforms to get one resulting waveform instead of a single scalar mean value!

So something like this should help:



Message Edited by GerdW on 03-28-2008 09:21 AM

Message Edited by GerdW on 03-28-2008 09:22 AM
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Download All
0 Kudos
Message 12 of 26
(1,634 Views)
Hi GerdW,
 
Now I understand that I misundestood. Smiley Sad
- Partha ( CLD until Oct 2027 🙂 )
0 Kudos
Message 13 of 26
(1,627 Views)
Averaging the waveforms alone may not produce the desired result unless the recordings are triggered in some way so that the waveforms are in phase. Keshav indicated that the recordings are from a soundcard, so I suspect that no triggering or synchronization has been done.

Without synchronization averaging 1000 waveforms will likely produce a meaningless result.

Does the waveform have a feature which can easily be distinguished in the soundcard output so that synchronization can be performed after recording but prior to averaging?

Lynn
0 Kudos
Message 14 of 26
(1,606 Views)

like Lynn said, when trying to improve the signal to noise ratio by taking many samplings and simply adding them, it's crucial that they are in phase (unless we are talking about a signal that has a very low frequency compared to (half) the samplerate.

 

Is it possible to maybe include a dirac-pulse for triggering?

My suggestion, if I were to do this, would to use something else than LabVIEW...something that handles array operations like this with ease(Matlab would be my choice).

but if you want to use Labview, and you can implement the sync-pulse, then the basics would be to:

Locate the position of the pulse in all of your 1000 sets, trim or shift 999 of them to match the remaining (so the dirac ends up at the same index in all sets) and then add the arrays, element wise, to eachother and divide the result by 1000 to get the proper scalingfactor. This would suppress any noise you have in your signal a great deal and most likely achieve what you want. But the crucial part is to get them in sync.

 

-Anders

0 Kudos
Message 15 of 26
(1,594 Views)
Hi, thanks for being so patient guys.

Lynn - Yes, the waveform is a response to a manually supplied stimulus, and I will be synchronizing the provision of stimulus with the start of recording (for each waveform).

GerdW - Thanks so much. I'll just try it out. One thing I didn't understand though, to initialize the SR with zero, why didn't you simply wire a numeric constant 0 to it? Why subtract the waveform from itself?

Cheers 🙂

0 Kudos
Message 16 of 26
(1,592 Views)
Hi keshav,

"why not use a zero constant?"

Because: you want to have an array of the same length as your waveform - the easiest is to use one waveform and to subtract from itself...
All your waveforms have the same length (aka sample count)?
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 17 of 26
(1,587 Views)
Hi GerdW ,
 
i had 2 doubts regarding the solution u gave ..
 
firstly, is that the index array block to the right of the first for loop ??
 
secondly, im not sure if this block diagram calculates the correct average...
say if we average 1, 2 and 3 ... its average shud be 2;   but as per the block diagram ... 
 
in the  first cycle,1 and 0 are added and then divided by N=1 ..producing 1.
In the 2nd cycle,  1 is added with 2 and then divided by N=2 to produce 1.5 .
In the 3rd cycle, 1.5 is added with 3 and then divided by N=3  which gives the incorrect average of 1,2 and 3 ..
please correct me if i have misunderstood your solution 
thnku
 
best regards,
MerSmiley Happy
0 Kudos
Message 18 of 26
(1,532 Views)


Mer wrote:
in the  first cycle,1 and 0 are added and then divided by N=1 ..producing 1.
In the 2nd cycle,  1 is added with 2 and then divided by N=2 to produce 1.5 .
In the 3rd cycle, 1.5 is added with 3 and then divided by N=3  which gives the incorrect average of 1,2 and 3 ..
please correct me if i have misunderstood your solution 

The division is done after the loop, the shift register contains the sum of all elements. After three iterations, the SR contains 1+2+3=6.
Once the loop is finished, it will divide by the total number of iterations, giving the averaged array.
0 Kudos
Message 19 of 26
(1,513 Views)


GerdW wrote:
Because: you want to have an array of the same length as your waveform - the easiest is to use one waveform and to subtract from itself...
All your waveforms have the same length (aka sample count)?

An alternative would be to place the first trace into the SR and then start adding at the second iteration. same result. 😮

 


Message Edited by altenbach on 04-03-2008 12:16 PM
0 Kudos
Message 20 of 26
(1,510 Views)