04-19-2016 12:36 AM
Hi,
First of all this is the first time i program in labview. I have a device that can measure radioactivity ( in disintegrations per minute ) and that device makes a sound everytime it gets a radioactivity signal, in labview i made an app that uses my laptop`s microphone to detect that sound ( high volume sounds ), and count the sounds, but my problem is that i need the counter to save values after every minute and than to give me a average of those values (for example first minute 5 signals so in the average box to be number 5, next minute i get 7 signals so the average box will show me 6 ). Can anyone please help me?
Solved! Go to Solution.
04-19-2016 01:45 AM
Hi Laurro,
- use ElapsedTime to determine your minute intervals.
- average := (average_previous + new_value)/(i+1) with "i" being the loop iterator. You need a shift register to hold the average_previous value
Both are basic LabVIEW concepts and you can learn them with all those free beginner resources offered by NI on their website (start here)!
04-19-2016 08:28 AM
thank you
04-19-2016 12:33 PM
@GerdW wrote:
- average := (average_previous + new_value)/(i+1) with "i" being the loop iterator. You need a shift register to hold the average_previous value
I don't believe this will give you the average of all values. For instance, when you get your 3rd value you want the average to be (A+B+C)/3. With your method, it will be
((A+B)/2+C)/3 = A/6+B/6+C/3 which is not equal. I think you want ( i * average_previous + new_value ) / ( i + 1 )
04-19-2016 01:32 PM
04-19-2016 01:38 PM
In a nutshell, you store all values into an array, add all those up, then divide by the array's size, so you get an average of all those. The array will determine how many times the for loop iterates, and by how much the result is divided, so you don't have to calculate that; if there was no data it will not iterate and just deliver a zero. Just remember to empty the array after each use.
04-19-2016 02:04 PM - edited 04-19-2016 02:05 PM
Hi Daikataro,
did you notice the SumArray function in the numerics palette before?
😄
(Some might say there already is a Mean function in the math palette, but I also stay away from it as it enforces an additional DLL bundled with an executable…)