# LabVIEW

cancel
Showing results for
Did you mean:

## moving average filter

I have a problem that I will describe:

I am receiving a continous stream of data,  in the form of an array.

however I want to do some processing on a smaller subset of the array, and obtain similar results to as if i was using the whole array.

the processing is:

1) recevie data&colon; 10 points

2) take mean of these 10 points

3) divide array/mean

and more processing which is not important.

the original array can have up to thousands of points. I know I can use a moving average, which i have done. so the average of the points 1:10 and 11:20 is the same as points 1:20.

however the problem is the third step, dividing each data by the mean.

in the end i want to plot the subset outputs, and i want it to be similar to processing the enitre data set.

Im not an expert in filters and all, but is there a good way to do this?

because the result i am getting now is quite choppy and unsmooth.

thanks!

Message 1 of 19
(2,651 Views)

## Re: moving average filter

You could calculate on 1:10 then 2:11 then 3:12, etc....  This may result in "smoother" data (a bit more processing), but I'm no mathematician.

Message 2 of 19
(2,647 Views)

## Re: moving average filter

If you are averaging data, and it is choppy, there are likely multiple things wrong.  The data is only going to be as good as the the sensor can measure.  And if you are getting crappy data at the sensor, then software should not be the one to fix it.  Fix the environment so the sensor gets the best data it can before software has to be involved.

That being said some times software filtering is needed and that's okay.  Try to post what an example of your code.  It is hard to understand what you are trying to do.  Do you want a moving window of data to average?  Or are you trying to understample where 10 values are now 1?

Message 3 of 19
(2,643 Views)

## Re: moving average filter

try the mean ptbypt function in a FOR loop with a useful sample lenght, then autoindex your array into it.

LabVIEW Champion. It all comes together in GCentral
What does "Engineering Redefined" mean??
Message 4 of 19
(2,640 Views)

## Re: moving average filter

the data is good.what i meant by choppy was the results of the subarray processing compared to the whole-array processing.

basically i want to perform the 3 steps for a whole data set(thousands of points) and for subarrays(7-10 points) and be able to get similar results.

right now the results arent very similar, it gets better if i increase the size of my subset array (obviously!). but the problem is since i only receive the data in small subsets(7-10) points, i want to process them right away, and not have to wait to get more points.

I have the whole array in advance, but just as a reference. the real problem is  assuming i only have access to the smaller subset of data points.

thanks a lot!!

Message 5 of 19
(2,636 Views)

## Re: moving average filter

Im not sure how this solves the problem...i;ve attached a vi that uses pt by pt mean.

Message 6 of 19
(2,621 Views)

## Re: moving average filter

Your VI contains no data in the array control.

LabVIEW Champion. It all comes together in GCentral
What does "Engineering Redefined" mean??
Message 7 of 19
(2,597 Views)

## Re: moving average filter

Oh sorry, but u can assume any input array, lets assume 1:10.
Message 8 of 19
(2,563 Views)

## Re: moving average filter

So why do you think it does not work? What result do you expect instead?

LabVIEW Champion. It all comes together in GCentral
What does "Engineering Redefined" mean??
Message 9 of 19
(2,550 Views)

## Re: moving average filter

ok lets say A = [1  2 3 4 5 6 7 8 9 10];

but I actually recevie it as B1 = [ 1 2 3 4 5] and B2 = [ 6 7 8 9 10]

the mean of B1 :3

mean of B2: 8

so the ouptuts would be C1 = B1/ meanB1 =  [ 1/3 2/3 3/3 4/3 5/3]

and C2 =  B2/ meanB2= [6/8 7/8 8/8 9/8 10/8]

the origianl array A would be: C3 =  A/meanA = [1/5.5, 2/5.5 ,3/5.5, 4/5.5, 5/5.5, 6/5.5 ,7/5.5,  8/5.5 , 9/5.5,  10/5.5]

so obviously plotting C1 and C2 (one after another) is not  the same as C3.

my goal is to make C1 and C2 as similar as possible to C3.

I hope this is more clear!

Message 10 of 19
(2,542 Views)