LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

simple moving average problem using filter express vi

Hi,

 

I am having some problems with filter express vi. I am trying to use it as moving average. 

I am feeding in a simple array of 10 numbers with the half-width of 2. But on the output, I don't get the correct filtered result. Is there something I am doing wrong here?

I have attached the sample VI I made for testing out the moving average function. 

 

Any help is appreciated. 


Thanks

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

The filter Express vi does not compute a simple moving average.  It applies a smoothing filter to the data.  it is bit different.

 

A simple moving average can be realized with this snippette:

!0.png


"Should be" isn't "Is" -Jay
0 Kudos
Message 2 of 8
(4,905 Views)

Hi Jeff,

 

I was trying to construct the VI according to the image you posted, but I am not sure what NaN stands for? Also, what's the subVI beside it (orange one with the arrow pointing left)

 

Thanks

 

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

NaN stands for Not a Number.  its a special case for IEEE 754 floating point numbers as are +/-inf.   The Feedback Node can be found on the structures pallatte.

 

Of course, that png shown is a "snippette."  just right-click it copy it paste it to your desktop and drag it onto a block biagram.  "Poof" the code is written! and hovering over the items with Ctrl+H on will take you right to the help file.


"Should be" isn't "Is" -Jay
0 Kudos
Message 4 of 8
(4,875 Views)

Or you can use PtByPt averaging.  Found in Signal Processing >> Point by Point >> Prob & Stat >> Mean

 

Capture.PNG

 

Sorry, mine is not a snippet.  Haven't installed that yet. 🙂

aputman
0 Kudos
Message 5 of 8
(4,857 Views)

 

Sorry, mine is not a snippet.  Haven't installed that yet. 🙂


 

 

I might be wrong, but I think the snippet is already a built-in Labview tool;

 

Here's a manual:

https://knowledge.ni.com/KnowledgeArticleDetails?id=kA03q000000x2PkCAI&l=en-US

 

 

 

Regards,
Alex

0 Kudos
Message 6 of 8
(4,852 Views)

@aputman wrote:

Or you can use PtByPt averaging.  Found in Signal Processing >> Point by Point >> Prob & Stat >> Mean

 

Capture.PNG

 

Sorry, mine is not a snippet.  Haven't installed that yet. 🙂


Not equvallent and will yeild strange results if number to average changes.  Placing Number to average outside the loop yields equivallent results(Given the same "Random numbers").  just a bit less Rube-GoldbergySmiley Wink

(Your Code: underneith...):

!0.png

Smiley Surprised


"Should be" isn't "Is" -Jay
0 Kudos
Message 7 of 8
(4,846 Views)

Thanks for the help everyone.

Looks like I got that part working now

Message 8 of 8
(4,817 Views)