LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

last 20 points

Hi

I am reading the temperature of a furnace, and I am finding that my data is
a little bit noisy. I do not need to store the data, I just need to be able
to plot it on a X-Y chart.

In order to smooth out the data, I have been performing a 20 point average
on it - each data point which is plotted is actually the average of the last
20 data points which were collected. I have done this by storing the data in
an array, and just taking a subset of the array to grab the last 20 points.

The problem with doing this, is that over time I am creating a very large
array (I am taking 5 data points a second). Is there any other way in which
I can average the last 20 collected data points, without having to store the
whole lot in an array?

Cheers


Jon Atkinson
0 Kudos
Message 1 of 3
(2,729 Views)
Most elegant I can think of offhand is to initialise an array at the start
of the program to as many elements as are needed. Every time a new reading
becomes available, use "rotate 1D array" such that element 0 is moved to
element 1 and the final element becomes element 0. Replace element zero with
your new data and average the whole array.

Dr Jon Atkinson wrote in message
news:9fg3ak$gpp$1@usenet.bham.ac.uk...

> The problem with doing this, is that over time I am creating a very large
> array (I am taking 5 data points a second). Is there any other way in
which
> I can average the last 20 collected data points, without having to store
the
> whole lot in an array?
Message 2 of 3
(2,729 Views)
Hello Jon! I haven't talked to you for a while.

What you can do is once your array is 20 elements in length (you can check it with the array length VI), start using the rotate 1D array VI. You can then rotate 1 element back, and then just write to the last element using replace element VI. Therefore, you'll rotate the array 1 element, forcing the oldest piece of data to the end of the array. Then, when you write your new piece of data to the end of the array, you'll replace the oldest data with the newest. Then just average that array.

Mark
Message 3 of 3
(2,729 Views)