Jump to content

how can i get average value every 10 data?


Recommended Posts

QUOTE (iriszhaoyu @ Apr 28 2009, 07:31 AM)

plz see the attachment ,I use a graph to describe my question. I want to caculate the average value of ten data,and only show the average value in the table.

can someone help me? thanks

A simple way to do this:

You can perform the basic math functions on arrays - add two arrays and they are added cellwise, New Array (0,0) = Array1 (0,0) times Array2 (0,0),...New Array (m,n) = Array1 (m,n) times Array2 (m,n).

Also subtraction, multiplication and division.

By creating a set of arrays like you have described in your image, you can then add them and divide the result by the scalar number of arrays added.

You can create the new arrays by simply using delete array element to eliminate the first element of the original array, then the 1st element of the new array, and so on. Add them together and the first element of the first array is added to the second element of the second array, is added to the third element of the third array. Divide that buy the number of arrays and you have the average of the first n elements.

I will give you an example that does this for an average of 5 elements, and I have included a VI that compares the effects of various filters in LabVIEW - Butterworth, Chebyshev, etc. This is very useful for selecting the best filter and finding (by trial and error) a set of coefficients that suits the needs of the anaysis. You can apply the filters overlaid upon the original data to intuitively examine phase shift, and so on.

Mike

Link to comment

I think what you are looking for is a running average. I think I found this piece of code on NIs website some time ago and I have found it handy when needing to do a simple quick filter. In the zip is the running average VI, and an example which just shows how to use it. Run the example then move the slider up and down and you'll see the running average on the slider next to it, and in a graph. By default is does a running average of the last 10 values but this can be changed.

BTW it is saved in 8.0

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.