09-27-2005 11:59 PM
I have to construct a VI that displays a random no. once every sec., and then in the same VI, i am trying to compute the average of the last four nos. generated, i.e. the average is displayed only after 4 numbers have been generated, else the average displays zero.
Well, i was trying to get this, but so far what i have got is a VI that is generating average, but that is not what i need.
Thanks for any help.
CL
09-28-2005 12:27 AM
Hi
Could you post your vi? If you're new to LV, it is better to advise you on the work you've already done, than just give you a solution.
Why do you want to display zero until you have 4 elements? Is there a reason for that?
Thomas
09-28-2005 02:02 AM
hi,
there is no reason in particular ro display 0, just set it up like that. I have worked on a VI that just computes the running avg. Here it is.
Thanks,
CL
09-28-2005 02:23 AM
09-28-2005 02:57 AM
Easiest would be to use "Mean PtByPt.vi" in the Analyze...Point by Point palette. It is most flexible, e.g. if you would want to change the averaging length in the future.
Alternatively, you could use shift registers initialized with NaN. I would prefer NaN over zero for incomplete samples, zero is not unique, it could be a legal value. See attached simple example (LabVIEW 7.1). Modify as needed.
09-28-2005 03:19 AM
09-28-2005 05:06 AM
Thanks all, for your kind help.
CL.