LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

simple moving average block diagram

Solved!
Go to solution

I am reading https://decibel.ni.com/content/docs/DOC-5041

 

and since I only have access to LabVIEW 6.1, I am interested in the block diagram JPG.

Unfortunately, I am getting an error when I click on the JPG.

 

Can someone help me out by posting it?

 

 

0 Kudos
Message 1 of 8
(5,350 Views)
Solution
Accepted by topic author nyc_(is_out_of_here)

Fwiw.

 

m.png

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

0 Kudos
Message 2 of 8
(5,347 Views)

Thank you.

0 Kudos
Message 3 of 8
(5,326 Views)

This seems like very clumsy code. For example if you later want to average more or fewer elements, you would basically need to rewrite the code from scratch. It is not scalable! Why would you need six diagam constants (DBL zero)? All you need is one and branch the wire. Why would you wire N of the FOR loop when autoindexing over the array? This is very crude beginner code that will only teach you bad habits. 😞

 

If you don't have access to the "ptbypt mean", you can make your own. Here is an old example (see lower part of code. The ptbypt version above it is just used to show that it gives the same result)

 

Try to implement it. To change the number of points to average, all you need to do is change a single integer. Since the mean does not care about the order of elements in the buffer, all you need is replace the oldest with the newest at each iteration, no need for rotating or shifting, etc.

 

 

 

Message 4 of 8
(5,316 Views)

I am not quite sure what to do when I have a finite set of data points; let's say 10.

If the numbers are 10,20,30,40,50,60,70,80,90,100.

I am adding 10,20,30,40,50 and taking the average.

Then I am adding 20,30,40,50,60 and taking the average.

and so forth.

When I reach the number 70 and want to take the average, I no longer have 5 numbers to average.

 

Am I approaching this correctly?

 

 

0 Kudos
Message 5 of 8
(5,296 Views)

If you only want results that contain the average of 10 values, your output array will be shorter accordingly.

 

My code starts averaging with the first element, so the first output would be the first input, the second output would be the average of the first and second input, etc. etc. and the last value would be the average of the last N point.

0 Kudos
Message 6 of 8
(5,288 Views)

@altenbach wrote:

If you only want results that contain the average of 10 values, your ourput array will be shorter accordingly.

 

My code starts averaging with the first element, so the first output would be the first input, the second output would be the average of the first and second input, etc. etc. and the last value would be the average of the last N point.


Using the set of 10 values above, the 1st average would be just be 10. The 2nd average would be (10+20)/2. The 3rd average would be (10+20+30)/30.

Am I understanding you correctly?

 

 

0 Kudos
Message 7 of 8
(5,283 Views)
Message 8 of 8
(5,280 Views)