LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

moving average for 10 values from an array

Hi,

 

I have to build an application wherein I continuosly get a values stored in an array of a fixed size 10. For every new time interval the last value is deleted and new value is added to the array.At a time 10 values are read and average is calculated. once I get the mean value , I have to compare with the min and max deviation from the mean. If the value of each array of a set is within the range then I have to provide a count which shows number of values in the array set of 10  else show the count as number of values outside the range. 

 

A set is of 10 values for each time interval.....

as

t0-t9 - 10 values....

t1-10- 10 values...

t2-t11 - 10 values..

and so on...

 

for all set i have to provide indication whether the set is valid or not....

 

 

 

Thanking you,

KHS

0 Kudos
Message 1 of 8
(4,186 Views)

Did you do the search that you were supposed to before you asked your question? I typed in "moving average" and the search engine immediately found 100 message threads, and would probably have found more if I had given it time. Many on the first page looked like exactly what you are asking about.

 

Cameron

 

To err is human, but to really foul it up requires a computer.
The optimist believes we are in the best of all possible worlds - the pessimist fears this is true.
Profanity is the one language all programmers know best.
An expert is someone who has made all the possible mistakes.

To learn something about LabVIEW at no extra cost, work the online LabVIEW tutorial(s):

LabVIEW Unit 1 - Getting Started</ a>
Learn to Use LabVIEW with MyDAQ</ a>
0 Kudos
Message 2 of 8
(4,157 Views)

I did that already, but don't seem to get a proper solution...

I am sorry but I am new to labview and working for the academic project which I have to submit within few days from now...

I appreciate your help... and I will try to cover up for me through many other posts...

 

Thanks !!!

0 Kudos
Message 3 of 8
(4,137 Views)

Hello,

 

You just want to know if your method is valid right?

It is when the array is full (10).

Had nothing to do so i changed your vi a bit, removed the for-loop and case structure.

 

Koen

 

---

UnCertified LabVIEW Student
Mistakes are for learning, that's why suggestions are always welcome!
Message 4 of 8
(4,110 Views)

hi,

 

 

I appreciate your help....!!

 

What I am actually looking is that, once

>  I get the first 10 ( at time interval t0-t9 and values as a0-a9 ) values in the array I should start processing the mean and not until the 10 arrays have been filled with the values......after first 10 values are filled, i  will check for the deviation for each array value from a0-a9, If in range it should indicate yes or else no.( this i already have ).

> once this is processed I should take the data set fom t1-t10, values as a1-a10......this will be my new set. Again I will follow the procedure for the mean check..

> This goes on continuously..... 

 

 

 

In the earlier vi of mine and in the later one of yours, in both the case the mean is calculated from the first value itself...which is not needed for my case.... 

It should only process once all 10 values are entered.. later for all set it should continuously process the mean....(since for lateral time i will always have 10 values in the array)...

 

 

I tried searching for this querry but could not find any proper solution...

 

I would really appreciate if I can be helped !!

 

Thanks in advance...!!

0 Kudos
Message 5 of 8
(4,105 Views)
Check number of non-zero elements in array and if its equal to 10 then calculate mean else don't calculate mean..
Thanks
uday
Message 6 of 8
(4,100 Views)

I don't really get your point.

You want a moving average from 10 points, this is what you already implemented.

But you don't want to average it untill you have your full 10 points?

If this is what you want there are two options.

1. you create a for-loop infront of the while loops which iterates 9 times your random generator, then connect it to the array shif register.

2. start with an empty array and let the mean calculate from less then 10 points till the array is full, this one is attached.

 

Koen

---

UnCertified LabVIEW Student
Mistakes are for learning, that's why suggestions are always welcome!
0 Kudos
Message 7 of 8
(4,094 Views)

The simplest way, based on your current VI, is to put a case structure around your mean and only calculate it when i (the iteration index) is greater or equal to 9 (the 10th iteration).


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 8 of 8
(4,072 Views)