Coefficient of Variation

Recommended Posts


I am using a LabJack U6 to read four pressure transducers and a EI1050 thermohygrometer. I am almost done with my project, the only piece missing is that I need to plot the Coefficient of Variation in Krough (which is calculated based on the pressure values) for the last 5 minutes of measurements. That is my first time using DAQFactory, and I am not sure how can I write a function for that.

If I use

StdDev(((pressure0- pressure1 )/2.745)/pressure1)/ Avg (((pressure0 - pressure1)/2.745)/pressure1) 

I will not get the last 5 minutes of measurements...

Thank you very much in advance


Ilaine Matos



Share this post

Link to post
Share on other sites

What is the actual formula (not in DAQFactory)?  

It looks like your graph is actually showing the last 25 minutes.  Are you just looking to get it based on the last five minutes?  In that case, you need to subset:

StdDev(((pressure0[systime(), systime() - 300]- pressure1[systime(), systime() - 300] )/2.745)/pressure1[systime(), systime() - 300])/ Avg (((pressure0[systime(), systime() - 300] - pressure1[systime(), systime() - 300])/2.745)/pressure1[systime(), systime() - 300]) 

It kind of gets hard to read this way, so you might consider creating a calculated V channel, so V.pressure0_5min might be pressure0[systime(),systime()-300], and the same for pressure1.  Then I'd create another calcuated V channel with the division, say v.kroughPreCalc

((v.pressure0_5min - v.pressure1_5min)/2.745)/v.pressure1_5min

Then the final expression just becomes:

stdDev(v.kroughPreCalc) / avg(v.kroughPreCalc)

Remember, when naming the V channel you don't put the V. in front.  That is just for accessing the data.

That all said, I would, in fact, if I was doing this, do it in a sequence that runs all the time and calculates this at the same interval as data comes in:

global Krough
private timeFrame = 300 // seconds
delay(timeframe) // wait 5 minutes for data to accumulate
   private p0 = pressure0[systime(), systime() - timeframe]
   private p1 = pressure1[systime(), systime() - timeframe]
   private precalc = (p0 - p1) / 2.745 / p1
   Krough = stdDev(precalc) / avg(precalc)
   delay(1) // gives an update rate of once a second...




Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now